GPT-6.1 Sol · 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 Haiku 5.5.
- Gold bugs found
- 0 of 0
- Comments published
- 5
- Comments matching a bug
- 0
- Comments not matching
- 5
- Cost of this PR
- $2.597
Published comments (5)
Client-credentials tokens encode an unknown grant instead of cc — Client-credentials tokens encode `na` because `ClientCredentialsGrantType.process` calls `generateAccessToken()` without the `Constants.GRANT_TYPE` attribute normally set by `createTokenResponse()`. Set that attribute before generating the access token so its encoded context identifies the actual grant.
Incorrect-grant test passes on an unrelated NullPointerException — Catching `RuntimeException` lets the test pass on a `NullPointerException` from uninitialized `sessionFactory`, even if unknown-grant validation is removed. Initialize `sessionFactory` with an empty provider stream and assert `IllegalArgumentException` specifically.
Invalid-width grant shortcuts produce token IDs that cannot be decoded — Custom shortcuts longer than two characters make `encodeTokenId` produce IDs that `getTokenContextFromTokenId` rejects with `IllegalArgumentException`. Validate that `gtf.getShortcut()` returns exactly two characters before registration, including dynamic paths, and document this constraint on the factory interface declaring `getShortcut()`. **Also found in:** - `server-spi-private/src/main/java/org/keycloak/protocol/oidc/grants/OAuth2GrantTypeFactory.java:30-31`
Grant matcher checks the wrong substring and accepts mismatched grants — Tokens with incorrect grants pass event assertions because `substring(3, 5)` reads the wrong segment and equality rejects matches rather than mismatches. Check the prefix length before using `substring(4, 6)`, and return false when it differs from `expectedGrantShortcut`.
Duplicated grantType check allows null rawTokenId — `AccessTokenContext` accepts a null `rawTokenId`, which `encodeTokenId` serializes as the literal suffix `:null` rather than preserving the original value. Change `Objects.requireNonNull` to check `rawTokenId` instead of checking `grantType` again.
Gold bugs found (0)
None.
Gold bugs missed (0)
None.