fix(config_edit): tolerate Loxone's value-identical duplicate attributes - #12
Open
tobsch wants to merge 1 commit into
Open
fix(config_edit): tolerate Loxone's value-identical duplicate attributes#12tobsch wants to merge 1 commit into
tobsch wants to merge 1 commit into
Conversation
Loxone emits the same attribute twice on some elements (observed: Title
on API-Connector elements, value-identical). xmltree's strict parser
rejected it ("Attribute 'Title' is redefined"), so every command that
edits a real config failed until the user pre-normalized externally.
ConfigEditor::load now drops the redundant, value-identical copy in a
quote-aware text pass before parsing (mirrors the existing
sanitize_digit_attrs preprocessing). Lossless — no write-back restore
needed. Duplicates with *different* values are left untouched so a
genuine conflict still surfaces at parse time.
Verified: a stock config straight from the Miniserver that previously
failed to parse now loads and runs `config check`. Adds 3 unit tests.
Fixes eisber#6
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V1TT6BSmf3uXakmtfexfDt
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.
Fixes #6.
Problem
A config downloaded straight from the Miniserver fails to parse in every edit-path command:
Loxone itself emits the same attribute twice on some elements (observed:
Titleon API-Connector elements), and the duplicates are value-identical.xmltree's strict parser rejects that, soconfig check/validate/add/wire/...are all blocked until the user pre-normalizes with an external tool.Fix
ConfigEditor::loadnow drops the redundant value-identical copy in a quote-aware text pass before parsing — mirroring the existingsanitize_digit_attrspreprocessing right next to it. Because the removed copy is identical, it's lossless, so (unlike the digit-attr rename) no write-back restoration is needed.Duplicates with different values are deliberately left untouched, so a genuine conflict still surfaces at parse time rather than being silently papered over.
Quote-aware because attribute values legitimately contain escaped angle brackets (
Unit="<v>%"); tag boundaries are found respecting"…".Verification
config check(no more parse error).cargo test dedupe→ 3 passed.cargo buildclean (no new warnings).🤖 Generated with Claude Code