-
Notifications
You must be signed in to change notification settings - Fork 387
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
Device Config form can be saved with required fields missing #2209
Comments
Hi @justjam2013 please install the beta version of config-ui-x where I have added a validation check for the config schema form. The UI (in the beta version) uses You might be able to create some custom validation messages from the docs here: although it is not something that I have really explored myself. Note that ideally plugins should still perform some checks on the user's config to avoid any type errors and plugin restart loops which may bring homebridge into a restart loop too. Let me know how it goes with any custom validation you try out! |
Hi @bwp91, I have updated to the beta version of config-ui-x and it works like a peach! When the config form starts up I see a red When all required fields have values, the red I fiddled around with making different fields required and non-required. The only debatable issue I found is that if a checkbox is required, then the form is blocked. To unblock form submission, I had to select and unselect the checkbox.
to the schema for the checkbox and that removes the need to select-select. In my opinion this is not a bug, but correct behavior. The schema specifically indicates that it is a required field, so the value must be explicit. So tried out the following validations:
In all cases, the validations prevented the green check mark and the I would say that it fully works as expected. Thank you for making the changes. Update: I also verified that if a field is required, but not visible, it does not affect the status of the Save button. |
I fully agree that plugins should perform checks. However, the plugin the plugin should be able to reasonably expect that the UI would honor the schema constraints, like In fact, it would be nice if config-ui called a Update:
|
Closing this bug as this now works as expected in the latest beta versions. |
Describe The Bug
I have the following defined in my config schema, where both the
name
andhasCellular
fields are required :In Config UI, I go ahead and configure in the Plugin Config window my iPad. Without entering a name for my iPad, I can click the
Save
button, which results in a valid json structure-wise, but not a valid iPad device, as I expect the fieldname
to be present in the config.I can check in the code to see if the name is present or not, then either fail to allow Homebridge to startup, or fail to load the malformed device and display an error in the log.
Homebridge Logs
widget on theStatus
screen, so the user may not realize that there was an error until they try to use the device and it doesn't show up.While option 2 works and I can check in code if the configuration is valid, it is not a good user experience. It would be reasonable for the user to expect that config ui would not save an invalid configuration.
My expectation is that
Save
button would be disabled until all required && visible fields are populatedNote: if a field is required, but not visible, it wouldn't affect the status of the
Save
button and wouldn't be saved in the configuration jsonNote:
If I go to the
Status
screen right after I press theSave button, then I see the logs scroll by, albeit very quickly, so I might still miss an error message displayed. But iIf I wait for the spinner to stop after I press the
Savebutton before I go to the
Statusscreen, this is what my
Homebridge Logs` widget looks like. It looks like Homebridge started up fine and everything is good.Logs
No response
Config
No response
Homebridge UI Version
4.62.0
Homebridge Version
1.8.4
Node.js Version
22.9.0
Operating System
macOS
Environment Info
Using hb-service
Raspberry Pi Model
None
The text was updated successfully, but these errors were encountered: