-
Notifications
You must be signed in to change notification settings - Fork 10
Config migration accepts keys the schema does not define #804
Copy link
Copy link
Open
Labels
BugSomething isn't workingSomething isn't workingInterraIssue has been imported to the Interra Board projectIssue has been imported to the Interra Board projectPriority 2: highPriority level 2: high time criticality or importancePriority level 2: high time criticality or importanceSoftwareRelating to software and implementationRelating to software and implementationimport
Description
Activity
Metadata
Metadata
Assignees
Labels
BugSomething isn't workingSomething isn't workingInterraIssue has been imported to the Interra Board projectIssue has been imported to the Interra Board projectPriority 2: highPriority level 2: high time criticality or importancePriority level 2: high time criticality or importanceSoftwareRelating to software and implementationRelating to software and implementationimport
Type
Projects
- StatusShow more project fieldsSoftware & tests
Problem description
tools/migrate_config_v2_to_v3.py::_validatestructures the migrated dictionary withcattrs.structure(nested_v3, Config)and checks nothing else.cattrsdiscards a key the schema does not define, so a migrated file carrying an orphan key structures cleanly and the tool reports the migration as a success. Every run made from that file afterwards sits on the schema default for that parameter, with nothing said at any point.A key the migration itself failed to translate is precisely the case this would catch, which makes the migration tool a poor place for the check to be absent.
#799 put
find_key_problemsin front of structuring wherever a configuration is loaded. The migration tool was outside that change, so it is now the one path that writes a config without accounting for its keys.Expected behavior
_validateruns the orphan-key walk before structuring and refuses to write a file whose keys it cannot account for, naming them the wayread_config_objectdoes.Evidence
tools/migrate_config_v2_to_v3.py, the body of_validate, in full:That is the entire validation.
My computer
macOS on arm64, Python 3.12.
Additional notes
proteus.config.read_config_objectalready composes reading, key-checking and structuring, but it takes a path and the tool holds a nested dict, so the fix is probablyfind_key_problemsfollowed by the existingcattrs.structurecall rather than a switch to the composed entry point.Relevant people
Nobody outside this repo; this one is mine.