-
-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent config fields being assigned to None in Generic Camera options #75299
Prevent config fields being assigned to None in Generic Camera options #75299
Conversation
55f4d76
to
39a0a02
Compare
39a0a02
to
cac735a
Compare
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. |
... |
Yes, @stalebot this is still valid and still wanted. |
Instead of the migration, which prevents reverting to an older HA core version, can't the problem be handled in the vol.Optional(
CONF_STILL_IMAGE_URL,
- description={"suggested_value": user_input.get(CONF_STILL_IMAGE_URL, "")},
+ description={"suggested_value": user_input.get(CONF_STILL_IMAGE_URL) or ""},
): str, |
Converting to draft as currently unable to reproduce the original problem. |
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. |
Closed and replaced with smaller PR: #86256 |
Proposed change
#75265 Adjusting the config for generic camera using the options flow resulted in some config fields being assigned to
None
in the stored config. These values are used as defaults when the user tries to configure a second time, but are rejected by the config validator. This PR prevents the problem and cleans up existing configs.Type of change
Additional information
During the options flow, a merge operation happens between the existing config and what the user has entered. The issue is that this merge uses the
get()
operation. If a field doesn't exist (ok for optional fields), theget()
operation returnsNone
. This then creates a field assigned toNone
, e.g.Actually this causes no problem initially because the
None
data is ignored by the integration base code. The problem is that thisNone
sits in the stored config and is put back to the UI on the second attempt. For the fields defined as optional with a data type ofstr
, this is invalid (the field can be omitted orstr
, but notNone
). So the user sees an error message. And there's not a lot they can do about it.This PR fixes the problem in two steps:
None
fields aren't assigned anymore.None
values on startup.Tests are added to ensure that the new code works.
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: