Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix appending the API_BODY_SUFFIX twice #36

Closed
wants to merge 3 commits into from
Closed

Conversation

nagisa
Copy link
Collaborator

@nagisa nagisa commented Oct 20, 2021

When the message batch approaches the limit we will hit the branch
within which we accidentally appended the trailing ]} twice to the
request body.

This branch was previously covered by our tests, in particular the
segmenter_preserves_order_when_splitting, but due to the lack of
assertions we never actually verified that the JSON we produce is valid.

Here we remove the invalid append, and some debug assertions as well as
a regression test for this issue.

NB: this is a short term fix before #34 is ready.

prost 0.7 uses `intersperse` of which there are two implementations
available – in itertools and, since recently, in the standard library.
These implementatinos are compatible, but the compiler is not able to
know which one is intended, so its an error.
When the message batch approaches the limit we will hit the branch
within which we accidentally appended the trailing `]}` twice to the
request body.

This branch was previously covered by our tests, in particular the
`segmenter_preserves_order_when_splitting`, but due to the lack of
assertions we never actually verified that the JSON we produce is valid.

Here we remove the invalid append, and some debug assertions as well as
a regression test for this issue.
@nagisa nagisa requested a review from rnarubin October 20, 2021 11:17
Off-by-ones are scary.
Copy link
Collaborator

@rnarubin rnarubin left a comment

Choose a reason for hiding this comment

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

bumping prost is a major version change -- I'm not opposed to that, but it would be a shame to tie that to this bug fix. Docs say this is still unstable https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.intersperse is it only a problem with users of recent nightly builds?

@nagisa
Copy link
Collaborator Author

nagisa commented Oct 20, 2021

Ah, it was in beta and would've made its way into stable… tomorrow. But I didn't see rust-lang/rust#89638, I'll undo the prost change.

Copy link
Collaborator

@rnarubin rnarubin left a comment

Choose a reason for hiding this comment

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

everything else looks good. Approved given the prost bump revert

@nagisa
Copy link
Collaborator Author

nagisa commented Oct 21, 2021

Merged in e698054

@nagisa nagisa closed this Oct 21, 2021
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