Skip to content

Config migration accepts keys the schema does not define #804

Description

@timlichtenberg

Problem description

tools/migrate_config_v2_to_v3.py::_validate structures the migrated dictionary with cattrs.structure(nested_v3, Config) and checks nothing else. cattrs discards 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_problems in 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

_validate runs the orphan-key walk before structuring and refuses to write a file whose keys it cannot account for, naming them the way read_config_object does.

Evidence

tools/migrate_config_v2_to_v3.py, the body of _validate, in full:

cattrs.structure(nested_v3, Config)

That is the entire validation.

My computer

macOS on arm64, Python 3.12.

Additional notes

proteus.config.read_config_object already composes reading, key-checking and structuring, but it takes a path and the tool holds a nested dict, so the fix is probably find_key_problems followed by the existing cattrs.structure call rather than a switch to the composed entry point.

Relevant people

Nobody outside this repo; this one is mine.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugSomething isn't workingInterraIssue has been imported to the Interra Board projectPriority 2: highPriority level 2: high time criticality or importanceSoftwareRelating to software and implementationimport

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions