Skip to content

core: Show JSON error offsets where possible#7437

Merged
francislavoie merged 1 commit intomasterfrom
json-err-offset
Jan 15, 2026
Merged

core: Show JSON error offsets where possible#7437
francislavoie merged 1 commit intomasterfrom
json-err-offset

Conversation

@francislavoie
Copy link
Member

After doing a bit of clicking around after #7436 I realized Go's json has a byte offset number for its errors which can be useful for figuring out exactly where a syntax error comes from in a huge JSON file in a pinch.

Assistance Disclosure

None

@francislavoie francislavoie added this to the v2.11.0 milestone Jan 14, 2026
Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

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

Thanks, this is great!

The linter is complaining about %w, it needs to be %s, or omit .Error().

Another suggestion might be to simply prepend or append something like "offset %d: " if the error type is applicable; for consistency, maybe could avoid repeating error message text.

Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

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

Nice. Thanks Francis!

@francislavoie francislavoie merged commit d269405 into master Jan 15, 2026
30 checks passed
@francislavoie francislavoie deleted the json-err-offset branch January 15, 2026 03:54
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