fix(mrml-core): warn on duplicate attributes and keep first value#638
Merged
jdrouet merged 1 commit intoApr 26, 2026
Merged
Conversation
79a90bc to
99dd60f
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #638 +/- ##
==========================================
+ Coverage 92.89% 92.96% +0.06%
==========================================
Files 227 206 -21
Lines 12203 11733 -470
==========================================
- Hits 11336 10907 -429
+ Misses 867 826 -41 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
990c212 to
80a1d1c
Compare
jdrouet
reviewed
Apr 25, 2026
Owner
jdrouet
left a comment
There was a problem hiding this comment.
Tiny optimization, mostly a nitpick 😉 But thanks a lot with that fix!
Comment on lines
+398
to
+402
| if result.contains_key(&name) { | ||
| cursor.add_warning(WarningKind::DuplicateAttribute, attr.span); | ||
| continue; | ||
| } | ||
| result.insert(name, attr.value.map(|inner| inner.to_string())); |
Owner
There was a problem hiding this comment.
This is a good fix but requires 2 accesses to the entry in the map.
Instead, could we use .entry(attr.qualified_name()) and, if it's occupied, we warn, instead we set it?
Contributor
Author
There was a problem hiding this comment.
Good catch! Fixed.
The shared parse_attributes_map helper silently overwrote earlier attribute values when the same attribute appeared twice on an element. Keep the first occurrence and emit a DuplicateAttribute warning on the span of the duplicate so callers can surface it. Signed-off-by: Federico Bond <federicobond@gmail.com>
80a1d1c to
42b410e
Compare
Owner
|
Thanks a lot for this! |
Open
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.
The shared
parse_attributes_maphelper silently overwrote earlier attribute values when the same attribute appeared twice on an element.I modified it to keep the first occurrence, which matches HTML and MJML behavior, and emit a DuplicateAttribute warning on the span of the duplicate so callers can surface it.