fix(hub): delete RefreshAgentToken dead code trap (#1337) - #1338
Open
ptone wants to merge 1 commit into
Open
Conversation
…1337) RefreshAgentToken mints credentials with NULL entitled_secret_keys and its underlying generator (GenerateAgentTokenWithExpiry) returns no JTI hash, making it impossible for callers to record entitled keys even knowing they should. This is a trap for any future caller: they get a working token, a credential that looks fine, and a wall. Both functions have zero production callers. The live token refresh path is handleAgentTokenRefresh (handlers_agents_core.go), which uses GenerateAgentToken (with JTI hash return) and records entitled keys. Deleted: - RefreshAgentToken (agenttoken.go) - GenerateAgentTokenWithExpiry (agenttoken.go) - CredentialChecker interface and SetCredentialChecker (agenttoken.go) - GetAgentCredentialByJTIHash on storeCredentialRecorder (server.go) - 6 RefreshAgentToken tests, 1 GenerateAgentTokenWithExpiry test - mockCredentialChecker test double (agenttoken_test.go) Callers searched: cmd/, internal/, all pkg/ packages, tests. Extent: grep -rn across entire repo for both function names. Zero production callers found.
17 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RefreshAgentTokenandGenerateAgentTokenWithExpiry— zero production callers, both are dead code trapsRefreshAgentTokenmints credentials with NULLentitled_secret_keysand its generator returns no JTI hash, making it impossible for callers to record entitled keysCredentialCheckerinterface,SetCredentialChecker, andmockCredentialCheckertest double — all existed solely forRefreshAgentTokenhandleAgentTokenRefresh(handlers_agents_core.go), which usesGenerateAgentToken(with JTI hash) and already records entitled keysWhy now
The fetch endpoint (PR 4) will read
entitled_secret_keysfor authorization. A NULL value from aRefreshAgentToken-minted credential would fail closed by design, but the function looks correct and the failure mode is invisible until an operator reports it. Removing it before PR 4 eliminates the trap.Caller search extent
Searched:
cmd/,internal/, allpkg/packages, all test files. Zero production callers.GenerateAgentTokenWithExpirycalled only byRefreshAgentToken(agenttoken.go:287) and one test.Tracking issue
Fixes #1337
Test plan
go vet ./pkg/hub/— cleango build ./...— cleanTestAgentTokenService_*— all pass (7 remaining tests)TestCredentialRecorderNilSafe— passesTestCredentialStoreOperations— passesTestComputeEntitledSecretKeys_*— all 8 pass (unaffected)