Skip to content

Conversation

@304
Copy link
Contributor

@304 304 commented Feb 2, 2026

Description

Prevent TypeError when decoding tokens with non-hash headers (e.g., arrays).

Fixes a TypeError where malformed tokens with array headers caused "no implicit conversion of String into Integer" error instead of raising the expected JWT::DecodeError.

Checklist

Before the PR can be merged be sure the following are checked:

  • There are tests for the fix or feature added/changed
  • A description of the changes and a reference to the PR has been added to CHANGELOG.md. More details in the CONTRIBUTING.md

@304 304 force-pushed the fix_type_error_2_segment_token_header branch from 7e4fd1d to 94b8a43 Compare February 2, 2026 14:02
Prevent TypeError when decoding tokens with non-hash headers (e.g.,
arrays).

Fixes a TypeError where malformed tokens with array headers caused "no
implicit conversion of String into Integer" error instead of raising the
expected JWT::DecodeError.
@304 304 force-pushed the fix_type_error_2_segment_token_header branch from 94b8a43 to aaa77a6 Compare February 2, 2026 14:17
it 'should raise JWT::DecodeError' do
expect do
JWT.decode data[:invalid_2_segment_header_token]
end.to raise_error JWT::DecodeError
Copy link
Member

@anakinj anakinj Feb 3, 2026

Choose a reason for hiding this comment

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

Could we check that the error message or that a part of it is the expected message? The JWT::DecodeError could basically be any of the errors raised.

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