Skip to content

Fix VehicleStatus timestamp drift for invalid placeholder values#393

Closed
tosate wants to merge 4 commits intoSAIC-iSmart-API:developfrom
tosate:fix/vehicle-timestamp-drift
Closed

Fix VehicleStatus timestamp drift for invalid placeholder values#393
tosate wants to merge 4 commits intoSAIC-iSmart-API:developfrom
tosate:fix/vehicle-timestamp-drift

Conversation

@tosate
Copy link
Copy Markdown
Contributor

@tosate tosate commented Nov 8, 2025

Fix VehicleStatus timestamp drift (#391)

Description

This pull request fixes the issue where MqttGatewayException was occasionally raised when the API returned the invalid timestamp 2147483647.

  • Invalid placeholder timestamps are now skipped.
  • Valid timestamps are correctly converted to datetime.
  • Drift checks still work for valid timestamps.

Fixes

nanomad added a commit to nanomad/saic-python-mqtt-gateway that referenced this pull request Mar 13, 2026
Add VehicleStatusDriftException to clearly distinguish timestamp drift
errors from unexpected failures. Invalid timestamps (None, 0, and
2147483647/Y2K38 sentinel) are now rejected upfront, and drifted
timestamps raise the same exception.

The vehicle handler catches this exception and logs a clean error
message instead of the alarming "unexpected exception" with a full
stack trace.

Closes SAIC-iSmart-API#410
Closes SAIC-iSmart-API#391
Closes SAIC-iSmart-API#263
Supersedes SAIC-iSmart-API#393

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@nanomad
Copy link
Copy Markdown
Contributor

nanomad commented Mar 13, 2026

Closing in favor of #427, which takes a different approach to the same problem.

This PR correctly identified 2147483647 as a bogus sentinel value, but it skipped the drift check and processed the vehicle status anyway. The issue is that when the timestamp is invalid, the rest of the payload is also unreliable — so processing it risks publishing stale or garbage data to MQTT.

#427 instead rejects the entire vehicle status update when the timestamp is bogus, and introduces a dedicated VehicleStatusDriftException so the error is logged cleanly (no more scary "unexpected exception" stack traces).

Thanks for the contribution and for identifying the Y2K38 sentinel value — we incorporated that into the fix!

@nanomad nanomad closed this Mar 13, 2026
nanomad added a commit to nanomad/saic-python-mqtt-gateway that referenced this pull request Mar 13, 2026
Add VehicleStatusDriftException to clearly distinguish timestamp drift
errors from unexpected failures. Invalid timestamps (None, 0, and
2147483647/Y2K38 sentinel) are now rejected upfront, and drifted
timestamps raise the same exception.

The vehicle handler catches this exception and logs a clean error
message instead of the alarming "unexpected exception" with a full
stack trace.

Closes SAIC-iSmart-API#410
Closes SAIC-iSmart-API#391
Closes SAIC-iSmart-API#263
Supersedes SAIC-iSmart-API#393

Co-Authored-By: Thomas Salm <tosate@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
nanomad added a commit that referenced this pull request Mar 13, 2026
Add VehicleStatusDriftException to clearly distinguish timestamp drift
errors from unexpected failures. Invalid timestamps (None, 0, and
2147483647/Y2K38 sentinel) are now rejected upfront, and drifted
timestamps raise the same exception.

The vehicle handler catches this exception and logs a clean error
message instead of the alarming "unexpected exception" with a full
stack trace.

Closes #410
Closes #391
Closes #263
Supersedes #393

Co-authored-by: Thomas Salm <tosate@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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.

2 participants