Skip to content

Remove deprecated API-key aliases and complete AgentID rename#7159

Merged
lpcox merged 3 commits into
mainfrom
copilot/duplicate-code-deprecated-api-key-alias-functions
Jun 7, 2026
Merged

Remove deprecated API-key aliases and complete AgentID rename#7159
lpcox merged 3 commits into
mainfrom
copilot/duplicate-code-deprecated-api-key-alias-functions

Conversation

Copilot AI commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

This change removes duplicate deprecated API-key forwarding functions that were kept after the AgentID rename, and migrates remaining usage to the canonical AgentID APIs. It also completes the unfinished rename of random key generation to the AgentID naming convention.

  • Problem summary

    • The codebase still exposed four old API-key-style entry points (three pure aliases plus one old-named generator), creating API surface duplication and ongoing cleanup debt.
  • Alias/API surface cleanup

    • Removed deprecated wrappers:
      • auth.ValidateAPIKey → use auth.ValidateAgentID
      • (*config.Config).GetAPIKey → use (*config.Config).GetAgentID
      • config.GetGatewayAPIKeyFromEnv → use config.GetGatewayAgentIDFromEnv
    • Updated in-code references/comments to point to AgentID APIs.
  • Generator rename completion

    • Renamed auth.GenerateRandomAPIKey to auth.GenerateRandomAgentID.
    • Updated the startup generation call path in internal/cmd/root.go to use the new symbol.
  • Test alignment

    • Updated random-agent-ID tests to the new function name.
    • Removed the now-obsolete alias test for ValidateAPIKey.
// before
randomKey, err := auth.GenerateRandomAPIKey()

// after
randomKey, err := auth.GenerateRandomAgentID()

Copilot AI changed the title [WIP] Remove deprecated API key alias functions Remove deprecated API-key aliases and complete AgentID rename Jun 7, 2026
Copilot finished work on behalf of lpcox June 7, 2026 17:01
Copilot AI requested a review from lpcox June 7, 2026 17:01
@lpcox lpcox marked this pull request as ready for review June 7, 2026 17:05
Copilot AI review requested due to automatic review settings June 7, 2026 17:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR continues the AgentID migration by removing deprecated API-key alias entry points, updating remaining call sites to use the canonical AgentID APIs, and completing the random key generator rename to match the AgentID naming convention.

Changes:

  • Removed deprecated alias functions for API-key-style accessors/validators in internal/auth and internal/config.
  • Renamed the random key generator from GenerateRandomAPIKey to GenerateRandomAgentID and updated the startup call path.
  • Aligned tests with the new generator name and removed the obsolete alias test.
Show a summary per file
File Description
internal/server/middleware.go Updates internal/auth API reference in the auth middleware comment.
internal/config/config_env.go Removes deprecated GetGatewayAPIKeyFromEnv wrapper.
internal/config/config_core.go Removes deprecated (*Config).GetAPIKey wrapper.
internal/cmd/root.go Switches startup random generation call to GenerateRandomAgentID.
internal/auth/header.go Removes deprecated ValidateAPIKey wrapper; renames random generator to GenerateRandomAgentID.
internal/auth/header_test.go Removes the now-obsolete ValidateAPIKey alias test.
internal/auth/apikey_test.go Renames random-generator tests to use GenerateRandomAgentID.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 7/7 changed files
  • Comments generated: 2

Comment thread internal/auth/header.go
Comment on lines +204 to 206
// GenerateRandomAgentID generates a cryptographically random agent ID.
// Per spec §7.3, the gateway SHOULD generate a random API key on startup
// if none is provided. Returns a 32-byte hex-encoded string (64 chars).
Comment on lines 88 to 91
// For header parsing logic, see internal/auth package which provides:
// - ParseAuthHeader() for extracting API keys and agent IDs
// - ValidateAPIKey() for key validation
// - ValidateAgentID() for key validation
func authMiddleware(apiKey string, next http.HandlerFunc) http.HandlerFunc {
@lpcox

lpcox commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator

@copilot resolve the merge conflicts in this pull request and address review feedback

Copilot AI commented Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request and address review feedback

Done in d1278af: I merged origin/main, resolved the conflicts, updated the conflicting review-comment text in internal/auth/header.go and internal/server/middleware.go, and fixed a merge-introduced duplicate extractSessionIDFromRequest in internal/server/session.go. Validation passed (go test ./internal/auth ./internal/server, make agent-finished, and parallel validation).

Copilot finished work on behalf of lpcox June 7, 2026 17:23
@lpcox lpcox merged commit fe67727 into main Jun 7, 2026
12 checks passed
@lpcox lpcox deleted the copilot/duplicate-code-deprecated-api-key-alias-functions branch June 7, 2026 17:26
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.

[duplicate-code] Duplicate Code Pattern: Deprecated API Key Alias Functions (4 instances across 3 packages)

3 participants