Skip to content

Invalidate the rendered token when detaching the payload - #757

Merged
anakinj merged 1 commit into
jwt:mainfrom
anakinj:fix/detach-payload-cache
Sep 5, 2026
Merged

anakinj merged 1 commit into
jwt:mainfrom
anakinj:fix/detach-payload-cache

Conversation

@anakinj

@anakinj anakinj commented Sep 5, 2026

Copy link
Copy Markdown
Member

Fixes #748

JWT::Token#jwt memoizes the rendered token, but #detach_payload! only set the detached flag. Detaching after the token had already been rendered kept handing out the cached attached token, so the result depended on call order.

detach_payload! now clears the memoized token, so the payload segment is rendered empty regardless of when it is called.

JWT::Token#jwt memoizes the rendered token, but #detach_payload! only
set the detached flag. Detaching after the token had already been
rendered therefore kept handing out the cached attached token, making
the result depend on call order.

detach_payload! now clears the memoized token so the payload segment is
rendered empty regardless of when it is called.

Fixes jwt#748
@anakinj
anakinj force-pushed the fix/detach-payload-cache branch from d435866 to 210671e Compare September 5, 2026 17:16
@anakinj
anakinj merged commit 41fbf31 into jwt:main Sep 5, 2026
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.

Token#detach_payload! keeps a cached attached JWT

1 participant