Skip to content

[Repo Assist] refactor: remove deprecated API key alias functions#7150

Merged
lpcox merged 2 commits into
mainfrom
repo-assist/refactor-remove-deprecated-apikey-aliases-7136-3179e7d1e136a906
Jun 7, 2026
Merged

[Repo Assist] refactor: remove deprecated API key alias functions#7150
lpcox merged 2 commits into
mainfrom
repo-assist/refactor-remove-deprecated-apikey-aliases-7136-3179e7d1e136a906

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented Jun 7, 2026

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

PR #7114 renamed the gateway's "API key" surface to "Agent ID" but left four deprecated one-liner wrapper functions in place as backwards-compat aliases. These create IDE confusion (autocomplete surfaces the old names) and an ongoing maintenance burden. This PR removes them.

Changes

Location Change
internal/auth/header.go Remove ValidateAPIKey() deprecated alias; rename GenerateRandomAPIKey()GenerateRandomAgentID()
internal/auth/header_test.go Remove TestValidateAPIKeyAlias (tests a now-deleted function)
internal/auth/apikey_test.go Rename all test functions and call sites to GenerateRandomAgentID
internal/cmd/root.go Update the single production caller to use GenerateRandomAgentID()
internal/config/config_core.go Remove GetAPIKey() deprecated alias (no non-definition callers)
internal/config/config_env.go Remove GetGatewayAPIKeyFromEnv() deprecated alias (no non-definition callers)
internal/server/middleware.go Update stale ValidateAPIKey() reference in doc comment

Verification

Confirmed no remaining references to the removed/renamed symbols via grep across the full source tree.

Test Status

Build and tests could not be run — proxy.golang.org is blocked in this environment (pre-existing infrastructure limitation). The changes are syntactically verified by inspection:

  • All callers of removed functions have been updated or removed
  • No remaining references to deprecated names in production code or tests
  • The rename is a mechanical sed-replace with no logic changes

Closes #7136

Warning

Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • proxy.golang.org
  • releaseassets.githubusercontent.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "proxy.golang.org"
    - "releaseassets.githubusercontent.com"

See Network Configuration for more information.

Generated by Repo Assist · sonnet46 8M ·

Add this agentic workflows to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@851905c06e905bf362a9f6cc54f912e3df747d55

The Agent ID rename (PR #7114) introduced four deprecated one-liner
wrapper functions that forward calls to the new AgentID-named functions.
These create a maintenance burden and IDE confusion (autocomplete
suggests the old names). All callers have been migrated:

- Remove ValidateAPIKey(): no non-test callers; remove TestValidateAPIKeyAlias
- Remove GetAPIKey() on Config: no callers outside its own definition
- Remove GetGatewayAPIKeyFromEnv(): no callers outside its own definition
- Rename GenerateRandomAPIKey() → GenerateRandomAgentID(): update the
  single production caller in internal/cmd/root.go and rename all tests
  in internal/auth/apikey_test.go

Also update the stale ValidateAPIKey() reference in the authMiddleware
doc comment in internal/server/middleware.go.

Closes #7136

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lpcox lpcox marked this pull request as ready for review June 7, 2026 16:52
Copilot AI review requested due to automatic review settings June 7, 2026 16:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 Agent ID terminology migration by removing deprecated “API key” alias wrapper functions that were left behind for backwards compatibility, and by renaming the remaining generator helper to the Agent ID name to reduce IDE/autocomplete confusion.

Changes:

  • Removed deprecated alias wrappers: ValidateAPIKey, (*Config).GetAPIKey, and GetGatewayAPIKeyFromEnv.
  • Renamed GenerateRandomAPIKey()GenerateRandomAgentID() and updated the single production call site plus tests.
  • Updated a stale doc comment reference from ValidateAPIKey() to ValidateAgentID().
Show a summary per file
File Description
internal/auth/header.go Removes deprecated validation alias and renames random generator to GenerateRandomAgentID.
internal/auth/header_test.go Deletes the alias-only test for ValidateAPIKey.
internal/auth/apikey_test.go Renames tests and call sites to GenerateRandomAgentID.
internal/cmd/root.go Updates the production caller to use GenerateRandomAgentID.
internal/config/config_core.go Removes deprecated GetAPIKey() accessor alias.
internal/config/config_env.go Removes deprecated GetGatewayAPIKeyFromEnv() alias.
internal/server/middleware.go Updates comment to reference the new validation function name.

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: 1

Comment thread internal/server/middleware.go Outdated
Comment on lines +88 to +90
// 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
@lpcox
Copy link
Copy Markdown
Collaborator

lpcox commented Jun 7, 2026

@copilot address review feedback

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 7, 2026

@copilot address review feedback

Addressed in commit 02c89e1: updated the authMiddleware doc comment to reference the helpers actually used (ParseAuthHeader and IsMalformedHeader) and clarified that credential validation is done via direct comparison in the middleware.

Copilot finished work on behalf of lpcox June 7, 2026 17:08
Copilot AI requested a review from lpcox June 7, 2026 17:08
@lpcox lpcox merged commit 239e934 into main Jun 7, 2026
16 checks passed
@lpcox lpcox deleted the repo-assist/refactor-remove-deprecated-apikey-aliases-7136-3179e7d1e136a906 branch June 7, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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