fix(parse): report a tagged NO/BAD instead of an empty result - #146
Open
giacomomasseron wants to merge 1 commit into
Open
giacomomasseron wants to merge 1 commit into
giacomomasseron wants to merge 1 commit into
Conversation
parse_ids, parse_capabilities, parse_noop and parse_metadata ended the
response stream at the command tag without reading its completion status,
so a command the server refused returned success with no data. A SEARCH
answered NO reached the caller as Ok({}) - the very value the server
sends when nothing matched, leaving callers no way to tell the two
apart.
Add command_completion, mirroring the status arms parse_status and
parse_mailbox already have, and consult it in those four parsers.
Unchanged on purpose: a stream that ends without a tagged completion
still succeeds (several existing tests feed exactly that shape), and
another command's completion is still ignored rather than failing ours
(8cdd3dc).
Tests: a tagged NO on SEARCH is an error; a tagged BAD on CAPABILITY is
an error; another command's NO in the same stream does not fail ours.
Contributor
|
sorry for talking a bit to get back. it generally looks ok on first read, could you rebase? sidenote: please make sure to always write all commit messages and PR descriptions by hand, see also https://delta.chat/en/community-standards#collective-maintenance-standards . thanks. |
Author
|
@hpk42 I can rebase, but honestly I can not go deep explaining the change, because my rust knowledge is limited. I understand your point, I think it's better for me to close this PR and open an issue about the problem. |
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 problem
parse_ids,parse_capabilities,parse_noopandparse_metadataend theresponse stream at the command's tag without reading the completion status:
So a command the server refused returns success with nothing in it. A
SEARCHansweredNOreaches the caller asOk({}).For a client that is not a difference it can defend against: an empty set is
also the normal answer to "nothing matched", so both outcomes arrive as the
same value. Concretely, a refused
UID SEARCH X-GM-LABELS "SomeLabel"reads as"no message carries that label", and a client that syncs labels then writes
that conclusion back - dropping labels the user set in the Gmail web UI. The
same shape affects
CAPABILITY,NOOPandGETMETADATA.parse_statusandparse_mailboxalready returnError::No/Error::Badhere. This brings the other parsers in line with them.
The change
One helper,
command_completion, returningOk(())forOKandError::No/Error::Badfor a refusal - the same armsparse_statusalready has - consulted by the four collect-style parsers.
Deliberately unchanged:
existing tests (
parse_ids_test,parse_ids_search,parse_capability_test)feed exactly that shape and expect
Ok.the case fixed in 8cdd3dc for
LOGIN. Covered by a test here.Tests
NOon SEARCH is an error, not an empty resultBADon CAPABILITY is an errorNOin the same stream does not fail oursNot included
parse_names,parse_fetchesandparse_expungereturn streams rather thancollecting, so surfacing a refusal there means yielding a final
Erriteminstead of ending the stream early. That is a larger change to the pipeline and
I left it out to keep this reviewable. Happy to follow up in the same shape if
you would like it.