Fix Header.parse scrambling every field - #24
Closed
gonzalocasas wants to merge 1 commit into
Closed
gonzalocasas wants to merge 1 commit into
gonzalocasas wants to merge 1 commit into
Conversation
Header.parse passed four values positionally into a constructor whose first parameter is increment_response_ID, so every field shifted by one: sequence_id landed in increment_response_ID, response_id in sequence_id, device_id in response_id, time_stamp in device_id, and time_stamp was regenerated. Verified over a live broker round-trip. This has been wrong since 26577b9 (2024-05-01), which added increment_response_ID as a new first parameter without updating the call site. The version before it read each field by name. Pass the fields as keyword arguments and restore the validation that commit dropped. Two related fixes: - The constructor used `sequence_id or default`, discarding a legitimate counter value of 0. Use `is None` instead. - parse() now accepts either the decoded wire dict or a Header instance. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Member
Author
|
Superseded by #25, which carries this exact commit plus the project-envelope fix, as the base of the messaging stack. Splitting this one out was only worth it if the header fix could reach users well ahead of the Model migration. With #23 now out of draft and mergeable, that gap has closed, so the duplicate review costs more than it buys. The fix itself is unchanged — same commit, reviewed in #25. |
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.
Header.parseshifts every field by one, and has done since 2024-05-01. This is onmain, so it affects anyone coordinating devices today.The bug
The constructor's first parameter is
increment_response_ID, so the four values land one slot to the left:sequence_idintoincrement_response_ID,response_idintosequence_id,device_idintoresponse_id,time_stampintodevice_id— andtime_stampitself is regenerated as "now".Observed on a live broker round-trip:
The message body survives; the header does not. Since
Headercarries the sequence and response IDs used to correlate requests with responses and to ignore self-sent messages, any multi-device coordination is running on scrambled values.Origin
26577b9(2024-05-01, "simplify messages.py and test inheritance from Message Class of compas_eve") addedincrement_response_IDas a new first parameter without updating the call site. The version before it read each field by name and validated.The fix
Pass the fields as keyword arguments and restore the validation that commit dropped. Two related fixes came out of it:
sequence_id or default, discarding a legitimate counter value of0. Nowis None.parse()accepts either the decoded wire dict or aHeaderinstance, since it is called both ways.Verification
Seven new tests cover field mapping, zero-valued counters, the validation error per missing field, and a full message round-trip. A live broker round-trip now reports
header intact: True.messages.pyis byte-identical betweenmainandrestructure, so this applies cleanly to both. The same commit also sits at the base of the restructure-side stack.🤖 Generated with Claude Code