GLM-5.3 Flash · Heavy

implement-access-token-context-encoding-framework-keycloak

Keycloak · Java · L · 300–799 lines · 6 files

The generalist plus 9 specialist lens agents in parallel, then the same verify and dedup steps. Judge: Claude Opus 5.5.

Gold bugs found
3 of 5
Comments published
3
Comments matching a bug
3
Comments not matching
0
Cost of this PR
$0.252

Published comments (3)

mediumbugservices/src/test/java/org/keycloak/protocol/oidc/encode/DefaultTokenContextEncoderProviderTest.java:76-85

testIncorrectGrantType passes via incidental NPE, not grant-type validation — Catching `RuntimeException` swallows an incidental NPE: `before()` never calls `factory.postInit()`, so `sessionFactory` stays null and the unknown shortcut throws before the intended `IllegalArgumentException`. Assert on `IllegalArgumentException` and initialize the factory so the validation path actually runs.

mediumbugservices/src/main/java/org/keycloak/protocol/oidc/encode/AccessTokenContext.java:72-73

Constructor guard re-validates grantType instead of rawTokenId — A null `rawTokenId` slips through this duplicate `grantType` check and later yields a corrupt token ID like "onrtna:null" in `DefaultTokenContextEncoderProvider.encodeTokenId` instead of failing fast. Make the second check require `rawTokenId`, matching its message.

mediumbugtestsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/AssertEvents.java:483

isAccessTokenId grant check uses wrong substring and inverted polarity, so it never fails — The wrong `substring` bounds and inverted polarity turn this check into a no-op, so token IDs with a wrong or missing grant type still match the event. Use `substring(4, 6)` and return false on mismatch.

Gold bugs found (3)

mediumThe AccessTokenContext constructor checks grantType twice instead of rawTokenId, so a null rawTokenId passes validation and is encoded as ':null'.
mediumisAccessTokenId reads the grant shortcut at the wrong offset (3,5 instead of 4,6) and inverts the comparison, so the event assertions never verify the token's grant type.
mediumtestIncorrectGrantType catches any RuntimeException, so it passes on a NullPointerException from the unset sessionFactory rather than verifying the unknown-grant IllegalArgumentException.

Gold bugs missed (2)

mediumClient-credentials (and UMA permission) token issuance never sets the GRANT_TYPE attribute, so their access token ids are encoded with the unknown grant 'na' instead of their shortcut.
mediumThe legacy token-exchange path in AbstractTokenExchangeProvider never sets Constants.GRANT_TYPE on the client session context, so tokens it issues are encoded with grant shortcut 'na' instead of the token-exchange shortcut.