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

proto: make invalid UTF-8 errors non-fatal #660

Merged
merged 1 commit into from
Aug 1, 2018
Merged

Conversation

dsnet
Copy link
Member

@dsnet dsnet commented Jul 27, 2018

The current logic currently treats RequredNotSetError as a non-fatal
error such that it continues to proceed with its normal execution, but
returns that non-fatal error at the end.

We now make it such that invalid UTF-8 is also a distinguishable error
that is treated as non-fatal by the execution logic. In the rare event
that both an RequiredNotSet error and InvalidUTF8 error is encountered,
the first one encountered is returned.

In the process of making this change, we also fix a number of cases where
RequiredNotSet was treated as fatal, when it should not have been non-fatal
(notably in the logic for extensions, message sets, and maps).

This change deliberately does not provide an API make it easy to distinguish
invalid UTF-8 errors as this is not a normal behavior we want users to
depend on. We can always expose additional API for this in the future.

Users can test for invalid UTF-8 with:
re, ok := err.(interface{ InvalidUTF8() bool })
isInvalidUTF8 := ok && re.InvalidUTF8()

The current logic currently treats RequredNotSetError as a non-fatal
error such that it continues to proceed with its normal execution, but
returns that non-fatal error at the end.

We now make it such that invalid UTF-8 is also a distinguishable error
that is treated as non-fatal by the execution logic. In the rare event
that both an RequiredNotSet error and InvalidUTF8 error is encountered,
the first one encountered is returned.

In the process of making this change, we also fix a number of cases where
RequiredNotSet was treated as fatal, when it should not have been non-fatal
(notably in the logic for extensions, message sets, and maps).

This change deliberately does not provide an API make it easy to distinguish
invalid UTF-8 errors as this is not a normal behavior we want users to
depend on. We can always expose additional API for this in the future.

Users can test for invalid UTF-8 with:
	re, ok := err.(interface{ InvalidUTF8() bool })
	isInvalidUTF8 := ok && re.InvalidUTF8()
@dsnet dsnet requested a review from neild July 27, 2018 19:51
@dsnet dsnet mentioned this pull request Jul 27, 2018
@dsnet
Copy link
Member Author

dsnet commented Jul 27, 2018

\cc @spenczar

@puellanivis
Copy link
Collaborator

Just as a note, the example test for invalid utf-8 combines an assignment with a logical operator. I’m sure it’s just a typo.

@dsnet
Copy link
Member Author

dsnet commented Jul 30, 2018

@puellanivis, I'm not sure I follow, which line are you referring to?

@dsnet dsnet merged commit f5983d5 into master Aug 1, 2018
@dsnet dsnet deleted the nonfatal-errors branch August 1, 2018 05:14
@golang golang locked and limited conversation to collaborators Jun 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants