Conversation
|
It is working in my side with ynput/ayon-nuke#344 (comment) through testing. |
|
This is just there to show that there's a bug that is solvable. The fix (created by AI) I'd say feels very off. I don't think we'd need to do this much mumbo jumbo and there must be an easier way. What I really think the issue is is that in most integrations some BaseSettingModels may not define |
There was a problem hiding this comment.
Pull request overview
This PR augments exported settings JSON schemas so that defaults for nested BaseSettingsModel fields (especially those created via default_factory and containing further nested defaults) are explicitly populated in the schema, enabling the frontend to prefill newly added list entries with deep defaults.
Changes:
- Added
populate_schema_defaults()to traverse a settings model + schema and inject missingdefaultvalues (including nested model defaults). - Called
populate_schema_defaults()in addon studio, site, and project schema endpoints beforepostprocess_settings_schema().
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| ayon_server/settings/postprocess.py | Adds schema traversal logic to populate missing defaults (including nested settings models). |
| api/addons/studio_settings.py | Populates schema defaults for addon studio settings schema responses. |
| api/addons/site_settings.py | Populates schema defaults for addon site settings schema responses. |
| api/addons/project_settings.py | Populates schema defaults for addon project settings schema responses. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if "default" not in child_schema: | ||
| default = get_field_default(field) | ||
| if default is not missing: | ||
| child_schema["default"] = default | ||
|
|
Description of changes
Fix nested SettingsModels like:
The defaults to
customkey should automatically be set when adding a new entry tooutputsin the Settings in frontend.Technical details
I feel like this 'fix' is way too convoluted and there must be something wrong - but just putting this as draft because it does resolve the issue here. However we should likely need to look at some other 'correct fix'.
Additional context
Solves case described here: ynput/ayon-nuke#344 (comment)
This is not a high priority at all.