Skip to content

Reraise unexpected lexer argument errors - #5711

Merged
rmosolgo merged 1 commit into
rmosolgo:masterfrom
ydah:reraise-unexpected-lexer-argument-errors
Aug 27, 2026
Merged

Reraise unexpected lexer argument errors#5711
rmosolgo merged 1 commit into
rmosolgo:masterfrom
ydah:reraise-unexpected-lexer-argument-errors

Conversation

@ydah

@ydah ydah commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

GraphQL::Language::Lexer#advance currently rescues every ArgumentError, but only handles errors whose message exactly matches "invalid byte sequence in UTF-8". Any other ArgumentError is silently swallowed and advance returns nil.

The exact message is produced while scanning an invalidly encoded string, so matching it also depends on Ruby's exception wording.

This PR validates the query string's encoding when the lexer is initialized and removes the broad rescue from advance. Invalid UTF-8 continues to raise the existing GraphQL::ParseError, while unrelated ArgumentErrors are propagated normally.

@rmosolgo rmosolgo added this to the 2.6.10 milestone Aug 27, 2026
@rmosolgo

Copy link
Copy Markdown
Owner

Thanks for this improvement!

@rmosolgo
rmosolgo merged commit 457c459 into rmosolgo:master Aug 27, 2026
14 of 15 checks passed
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