🔍 Duplicate Code Pattern: Deprecated API Key Alias Functions
Part of duplicate code analysis: #aw_parentreport1
Summary
The Agent ID rename commit introduced 4 deprecated single-line wrapper functions that follow the exact same pattern across 3 packages. Each wrapper calls the new AgentID-named function. These create an ongoing maintenance burden — callers must be found and migrated before the aliases can be removed.
Duplication Details
Pattern: One-liner deprecated wrapper delegating to the renamed function
- Severity: Medium
- Occurrences: 4 instances across 3 packages
- Locations:
internal/auth/header.go (line 123–125)
internal/config/config_core.go (line 186–188)
internal/config/config_env.go (line 82–84)
internal/auth/header.go (line 209–220) — GenerateRandomAPIKey retains old external name without a new-named counterpart
Code Samples:
// internal/auth/header.go
// ValidateAPIKey is a deprecated alias for ValidateAgentID.
func ValidateAPIKey(provided, expected string) bool {
return ValidateAgentID(provided, expected)
}
// internal/config/config_core.go
// GetAPIKey is a deprecated alias for GetAgentID.
func (c *Config) GetAPIKey() string {
return c.GetAgentID()
}
// internal/config/config_env.go
// GetGatewayAPIKeyFromEnv is a deprecated alias for GetGatewayAgentIDFromEnv.
func GetGatewayAPIKeyFromEnv() string {
return GetGatewayAgentIDFromEnv()
}
Additionally, GenerateRandomAPIKey() in internal/auth/header.go retains the old naming with no new-named equivalent, and its single caller in internal/cmd/root.go:277 still uses the old name.
Impact Analysis
- Maintainability: Four deprecated wrapper functions across 3 packages must all be removed in a future cleanup pass. New contributors may use the old names when writing code (IDEs will suggest deprecated names).
- Bug Risk: Low — wrappers are trivial one-liners. Risk is that callers are never migrated and old names persist indefinitely.
- Code Bloat: ~15 lines of pure forwarding code that adds noise to the API surface.
Refactoring Recommendations
-
Audit callers of all deprecated functions (including in test files) to confirm readiness for removal:
ValidateAPIKey (callers outside _test.go?)
GetAPIKey (callers outside _test.go?)
GetGatewayAPIKeyFromEnv (callers?)
GenerateRandomAPIKey — internal/cmd/root.go:277
-
Rename GenerateRandomAPIKey → GenerateRandomAgentID in internal/auth/header.go and update its single caller in root.go:277. This function was not given a forwarding alias unlike the others.
-
Remove deprecated wrappers once all callers are migrated:
- Estimated effort: 1–2 hours (audit + search-replace + test run)
- Benefits: Removes ambiguity, shrinks public API surface, eliminates confusion about which name to use
Implementation Checklist
Parent Issue
See parent analysis report: #aw_parentreport1
Generated by Duplicate Code Detector · sonnet46 4.3M · ◷
🔍 Duplicate Code Pattern: Deprecated API Key Alias Functions
Part of duplicate code analysis: #aw_parentreport1
Summary
The Agent ID rename commit introduced 4 deprecated single-line wrapper functions that follow the exact same pattern across 3 packages. Each wrapper calls the new
AgentID-named function. These create an ongoing maintenance burden — callers must be found and migrated before the aliases can be removed.Duplication Details
Pattern: One-liner deprecated wrapper delegating to the renamed function
internal/auth/header.go(line 123–125)internal/config/config_core.go(line 186–188)internal/config/config_env.go(line 82–84)internal/auth/header.go(line 209–220) —GenerateRandomAPIKeyretains old external name without a new-named counterpartCode Samples:
Additionally,
GenerateRandomAPIKey()ininternal/auth/header.goretains the old naming with no new-named equivalent, and its single caller ininternal/cmd/root.go:277still uses the old name.Impact Analysis
Refactoring Recommendations
Audit callers of all deprecated functions (including in test files) to confirm readiness for removal:
ValidateAPIKey(callers outside_test.go?)GetAPIKey(callers outside_test.go?)GetGatewayAPIKeyFromEnv(callers?)GenerateRandomAPIKey—internal/cmd/root.go:277Rename
GenerateRandomAPIKey→GenerateRandomAgentIDininternal/auth/header.goand update its single caller inroot.go:277. This function was not given a forwarding alias unlike the others.Remove deprecated wrappers once all callers are migrated:
Implementation Checklist
grep -rn "ValidateAPIKey\|GetAPIKey\|GetGatewayAPIKeyFromEnv\|GenerateRandomAPIKey"to find all remaining callersGenerateRandomAPIKey→GenerateRandomAgentIDand update call site inroot.gomake test-allto verifyParent Issue
See parent analysis report: #aw_parentreport1