fix(config): make migrate-config --in-place idempotent#3110
Merged
Conversation
Replace toml_edit::contains_key() idempotency guards with raw-string
toml_src.contains() checks in all affected migration functions. The
contains_key approach silently failed because commented-out entries are
invisible to the TOML parser — the guard always passed on second run,
causing duplicated section-header comments and duplicated commented keys.
Replace append_comment_to_table_suffix / toml_edit decor manipulation
with format!("{raw}{comment}") direct string appends to avoid the decor
round-trip bug where toml_edit attributes trailing comments to the next
section's prefix on re-parse.
Add insert_after_section() helper for migrate_otel_filter so its comment
is inserted within [telemetry] rather than appended to end of file.
Add 8 idempotency tests covering all fixed migration functions; second
run now reports 0 entries added and leaves the file unchanged.
Fixes #3095
e29aaf2 to
441f205
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.
Summary
toml_edit::contains_key()idempotency guards withtoml_src.contains()raw-string checks in all affected migration functions — the old approach silently failed because TOML comments are invisible to the parserappend_comment_to_table_suffix/toml_editdecor manipulation withformat!("{raw}{comment}")direct string appends to fix the decor round-trip bug (trailing comments re-attributed to next section's prefix on re-parse)insert_after_section()helper somigrate_otel_filtercomment is inserted within[telemetry]rather than at end of fileTest plan
cargo nextest run -p zeph-config --lib— 262/262 pass[agent]# ...) on second runFixes #3095