Skip to content

Fix minor regressions in legacy error strings #130

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

Merged
merged 1 commit into from
Jan 14, 2025
Merged

Conversation

dsnet
Copy link
Collaborator

@dsnet dsnet commented Jan 14, 2025

The Go 1 compatability document does not guarantee that error strings remain unchanged across Go releases. However, there is a practical benefit of reducing the churn even if this is not a guaranteed property.

Adjust the formatting of v1 error strings to better match how they were historically rendered. This does not ensure 100% equivalency with legacy error strings, but
does a better job at mostly preserving the exact string.

In the jsontext and jsonwire packages, we make changes to assist in the construction legacy error values. We also make syntactic errors returned by the Decoder more consistent regardless of whether they were produced by a ReadValue or ReadToken call.

@dsnet dsnet force-pushed the legacy-error-strings branch 2 times, most recently from 867ce90 to 5346743 Compare January 14, 2025 11:08
Copy link
Collaborator

@mvdan mvdan left a comment

Choose a reason for hiding this comment

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

Hopefully the quality of v2 errors is not reduced by this :)

@dsnet
Copy link
Collaborator Author

dsnet commented Jan 14, 2025

Hopefully the quality of v2 errors is not reduced by this :)

I only kept changes in v2 that were objectively an improvement. All the gross stuff was shoved into v1.

@dsnet dsnet force-pushed the legacy-error-strings branch from 5346743 to d3b4f71 Compare January 14, 2025 20:19
The Go 1 compatability document does not guarantee that
error strings remain unchanged across Go releases.
However, there is a practical benefit to reducing the churn
even if this is not a guaranteed property.

Adjust the formatting of v1 error strings to better match
how they were historically rendered. This does not ensure
100% equivalency with legacy error strings, but
does a better job at mostly preserving the exact string.

In the jsontext and jsonwire packages, we make changes
to assist in the construction legacy error values.
We also make syntactic errors returned by the Decoder more
consistent regardless of whether they were produced by a
ReadValue or ReadToken call. All changes made to jsontext
and jsonwire are an improvement, so we are not taking on
technical debt in those packages to support legacy error strings.
All legacy transformations are kept in the v1 code.
@dsnet dsnet force-pushed the legacy-error-strings branch from d3b4f71 to 39d5674 Compare January 14, 2025 20:21
@dsnet dsnet merged commit ac4e8cd into master Jan 14, 2025
8 checks passed
@dsnet dsnet deleted the legacy-error-strings branch January 14, 2025 20:24
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.

3 participants