[dev] C4 - add config migration system#3197
Merged
deruyter92 merged 13 commits intoFeb 20, 2026
Merged
Conversation
21 tasks
C-Achard
reviewed
Feb 3, 2026
Collaborator
C-Achard
left a comment
There was a problem hiding this comment.
Love this ! The tricky part will be in the actual conversion but otherwise this is nice, just consider adding better error handling/edge case testing/debug outputs/graceful error handling where relevant
00fd419 to
94cdc66
Compare
Base automatically changed from
jaap/replace_config_loaders_with_typed
to
feat/structured_configs
February 5, 2026 16:07
275d3f4 to
e002bdc
Compare
4fe72b4 to
c00ed43
Compare
760c7ae to
00e2b77
Compare
b0df8a3 to
9e81b55
Compare
Base automatically changed from
jaap/cfg_3b_additional_fixes
to
feat/structured_configs
February 20, 2026 07:49
…ith validate_assignment=True) This is necessary to prevent a bug: The isinstance(data, cls): return data shortcut in MigrationMixin.migrate_then_validate (a model_validator(mode="wrap")). Pydantic re-enters this validator during validate_assignment, passing the current instance as data. The shortcut returned it unchanged, silently discarding every field update. This broke all assignment — not just validation, but even plain cfg.count = 42 was a no-op. The problem is that model_validator(mode="wrap") wraps the entire validation pipeline, including validate_assignment flow. Migration should only run during construction, not on every field assignment. The clean solution is to switch from mode="wrap" to mode="before" — it transforms raw input data before validation and doesn't participate in validate_assignment at all.
9e81b55 to
62d98ee
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is part of the WIP for migrating from dictionary configs to typed & validated configurations (see #3193 for an overview).
Introduces a config versioning and migration system for configurations. This facilitates easier changing of configuration schemas while keeping backward compatibility and reducing risks of missing-field-errors.
Changes
MigrationMixinclass can be used as mixin for dataclasses to facilitate easy migration. It enables automatic loading and validation of earlier configurations into the current versions format.Usage
After applying changes to the configuration dataclass (e.g. renaming of fields, or changing value types), the
CURRENT_CONFIG_VERSIONshould be incremented accordingly (e.g. from 0 to 1). The corresponding transformations from the old field to the new field can be added to a migration function. e.g.migrate_v0_to_v1.For instance when deciding that value 'MULTI!' for field
bodypartsshould be converted to an empty list, one can add the following transformation: