Skip to content

fix(config_edit): tolerate Loxone's value-identical duplicate attributes - #12

Open
tobsch wants to merge 1 commit into
eisber:mainfrom
tobsch:fix/parse-duplicate-attributes
Open

fix(config_edit): tolerate Loxone's value-identical duplicate attributes#12
tobsch wants to merge 1 commit into
eisber:mainfrom
tobsch:fix/parse-duplicate-attributes

Conversation

@tobsch

@tobsch tobsch commented Aug 25, 2026

Copy link
Copy Markdown

Fixes #6.

Problem

A config downloaded straight from the Miniserver fails to parse in every edit-path command:

Error: Failed to parse Loxone XML: Malformed XML. 1218:211 Attribute 'Title' is redefined

Loxone itself emits the same attribute twice on some elements (observed: Title on API-Connector elements), and the duplicates are value-identical. xmltree's strict parser rejects that, so config check/validate/add/wire/... are all blocked until the user pre-normalizes with an external tool.

Fix

ConfigEditor::load now drops the redundant value-identical copy in a quote-aware text pass before parsing — mirroring the existing sanitize_digit_attrs preprocessing 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

  • A stock config straight from the Miniserver that previously failed to parse now loads and runs config check (no more parse error).
  • 3 unit tests added: value-identical dup collapses & parses; different-value dup still errors; quote-aware value is untouched. cargo test dedupe → 3 passed.
  • cargo build clean (no new warnings).

🤖 Generated with Claude Code

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parse fails on Loxone's own value-identical duplicate attributes (Title redefined)

1 participant