MigrateConfig: stop duplicating options that have an empty value in the template - #950
Open
Cybis320 wants to merge 1 commit into
Conversation
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.
Problem
MigrateConfigwrites a duplicate entry for any option whose template value is empty, producing a.configthat RMS cannot read:configparserthen raisesDuplicateOptionErrorand RMS crashes on startup.Two options in the template have empty values, and both are affected:
time_server:(.config:62)win_pc_weave:(.config:392)Cause
Attribute lines were parsed with
re.split(": ", l), which requires a colon followed by a space. Lines with an empty value do not match, so in the template merge loop they took thecnt != 2branch: the template line was written out verbatim and the key was never removed fromattributes_dict. It then fell through to the "unrecognized attributes preserved" step, where the option is valid perConfigReader.py, so it was appended a second time.The crash only shows up when the user's config has a non-empty value for one of these options, which is why it went unnoticed.
Fix
parseAttributeLine()helper using^([^:]+?)\s*:\s*(.*)$, replacing bothre.split(": ", ...)sites. It handles empty values and makes the space after the colon optional —linux_pc_weave:-O2was previously dropped silently, losing the user's setting.rpi_weave:, notrpi_weave:).configparserdoes). This backstops the same crash from any other parse gap or case mismatch.Testing
win_pc_weave/time_server,DuplicateOptionError. After: values kept in place, config parses,win_pc_weave = '-Wall'.duplicate value for win_pc_weave, assuming last value, keeps-Wall, and emits a single valid entry. Affected stations can just re-runpython -m Utils.MigrateConfig -u..configmigrated against itself) is byte-identical apart from the added; Reformated byfooter — no drift across the other 190 attributes.device: rtsp://...).🤖 Generated with Claude Code