Skip to content

EU Data Act: prefer current mileage.value key for odometer - #35294

Merged
andig merged 2 commits into
masterfrom
fix/eudataact-odo-key
Oct 25, 2026
Merged

andig merged 2 commits into
masterfrom
fix/eudataact-odo-key

Conversation

@andig

@andig andig commented Oct 25, 2026

Copy link
Copy Markdown
Member

fixes #35100

VW delivers two mileage.value entries in random order. Name lookup picks whichever comes first, so the odometer jumps between the current and a stale value. Key 69d437d3 tracks the app according to the reporter and is now looked up first.

🤖 Generated with Claude Code

refs #35100

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@andig andig added the vehicles Specific vehicle support label Oct 25, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="vehicle/vw/eudataact/provider.go" line_range="136" />
<code_context>
 	}

-	if p := lookup(data, FieldOdometer, FieldOdometerValue); p != nil {
+	if p := lookup(data, KeyMileageValue, FieldOdometer, FieldOdometerValue); p != nil {
 		return strconv.ParseFloat(p.Value, 64)
 	}
</code_context>
<issue_to_address>
**Stale mileage overrides current reading**

When both the current-key point and a fallback mileage point are present, and the fallback has a higher `Seq`, `lookup` compares `Seq` across matches before honoring the exact-key match, so the fallback overrides the current-key point and `Odometer` returns stale mileage.

Prioritize the exact-key point over fallback name matches, regardless of `Seq`.
</issue_to_address>

### Comment 2
<location path="vehicle/vw/eudataact/provider.go" line_range="136" />
<code_context>
 	}

-	if p := lookup(data, FieldOdometer, FieldOdometerValue); p != nil {
+	if p := lookup(data, KeyMileageValue, FieldOdometer, FieldOdometerValue); p != nil {
 		return strconv.ParseFloat(p.Value, 64)
 	}
</code_context>
<issue_to_address>
**Invalid mileage prevents fallback**

When the preferred-key point has a nonnumeric value while a fallback mileage point has a valid value, `Odometer` parses only the selected point and returns its parse error, so a malformed value for the preferred key masks a valid fallback mileage and the caller gets no odometer reading.

Try the remaining matching mileage points if parsing the preferred point fails, and return an error only if none parse successfully.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread vehicle/vw/eudataact/provider.go Resolved
Comment thread vehicle/vw/eudataact/provider.go Resolved
Comment thread vehicle/vw/eudataact/eudataact_test.go Resolved
@andig
andig enabled auto-merge (squash) October 25, 2026 10:46
@andig
andig merged commit 8e77086 into master Oct 25, 2026
12 checks passed
@andig
andig deleted the fix/eudataact-odo-key branch October 25, 2026 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vehicles Specific vehicle support

Projects

None yet

1 participant