Skip to content

Commit 5c70db9

Browse files
somanshreddyclaude
andcommitted
fix: consolidate API key settings URL into a single constant
The old /settings/api path no longer exists. Replace all occurrences with the working https://app.heygen.com/settings?nav=API URL and extract it as APIKeySettingsURL in internal/errors so every hint references the same constant. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent cb95b6c commit 5c70db9

5 files changed

Lines changed: 15 additions & 9 deletions

File tree

cmd/heygen/auth.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
package main
22

3-
import "github.com/spf13/cobra"
3+
import (
4+
"github.com/spf13/cobra"
5+
6+
clierrors "github.com/heygen-com/heygen-cli/internal/errors"
7+
)
48

59
// authGuidance is the single source of truth for how to set up CLI auth.
610
// Referenced by auth_login.go, auth_status.go, and the auth group help below.
7-
const authGuidance = `Three ways to provide your API key:
11+
var authGuidance = `Three ways to provide your API key:
812
1. Environment variable (current shell only):
913
export HEYGEN_API_KEY=<your-key>
1014
2. Pipe to auth login (saves to ~/.heygen/credentials):
@@ -14,7 +18,7 @@ const authGuidance = `Three ways to provide your API key:
1418
1519
When both env var and stored credential are set, the env var takes priority.
1620
17-
Get a key: https://app.heygen.com/settings/api`
21+
Get a key: ` + clierrors.APIKeySettingsURL
1822

1923
func newAuthCmd(ctx *cmdContext) *cobra.Command {
2024
cmd := newCommandGroup("auth", "Manage authentication")

cmd/heygen/auth_status_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func TestAuthStatus_AuthError_AddsHint(t *testing.T) {
8282
if !strings.Contains(res.Stderr, "HEYGEN_API_KEY environment variable") {
8383
t.Fatalf("stderr should mention env var source:\n%s", res.Stderr)
8484
}
85-
if !strings.Contains(res.Stderr, "app.heygen.com/settings/api") {
85+
if !strings.Contains(res.Stderr, "app.heygen.com/settings?nav=API") {
8686
t.Fatalf("stderr should contain key generation URL:\n%s", res.Stderr)
8787
}
8888
}
@@ -124,7 +124,7 @@ func TestAuthStatus_NoKey(t *testing.T) {
124124
if !strings.Contains(res.Stderr, "Three ways to provide your API key") {
125125
t.Fatalf("stderr = %s, want auth guidance", res.Stderr)
126126
}
127-
if !strings.Contains(res.Stderr, "app.heygen.com/settings/api") {
127+
if !strings.Contains(res.Stderr, "app.heygen.com/settings?nav=API") {
128128
t.Fatalf("stderr = %s, want key URL in hint", res.Stderr)
129129
}
130130
}

cmd/heygen/context.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ func enrichAuthHint(cliErr *clierrors.CLIError, source auth.CredentialSource) {
7979
credPath := filepath.Join(paths.ConfigDir(), "credentials")
8080
switch source {
8181
case auth.SourceEnv:
82-
cliErr.Hint = "The HEYGEN_API_KEY environment variable contains an invalid or expired key.\nGenerate a new key: https://app.heygen.com/settings/api"
82+
cliErr.Hint = "The HEYGEN_API_KEY environment variable contains an invalid or expired key.\nGenerate a new key: " + clierrors.APIKeySettingsURL
8383
case auth.SourceFile:
84-
cliErr.Hint = fmt.Sprintf("The stored API key (%s) is invalid or expired.\nReplace it: heygen auth login\nGenerate a new key: https://app.heygen.com/settings/api", credPath)
84+
cliErr.Hint = fmt.Sprintf("The stored API key (%s) is invalid or expired.\nReplace it: heygen auth login\nGenerate a new key: %s", credPath, clierrors.APIKeySettingsURL)
8585
}
8686
}
8787

cmd/heygen/context_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func TestEnrichAuthHint_EnvSource_401(t *testing.T) {
2727
if !strings.Contains(res.Stderr, "HEYGEN_API_KEY environment variable") {
2828
t.Fatalf("stderr should mention env var source:\n%s", res.Stderr)
2929
}
30-
if !strings.Contains(res.Stderr, "app.heygen.com/settings/api") {
30+
if !strings.Contains(res.Stderr, "app.heygen.com/settings?nav=API") {
3131
t.Fatalf("stderr should contain key generation URL:\n%s", res.Stderr)
3232
}
3333
}

internal/errors/errors.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ const (
1212
ExitTimeout = 4
1313
)
1414

15+
const APIKeySettingsURL = "https://app.heygen.com/settings?nav=API"
16+
1517
// CLIError is the canonical error type for all CLI operations.
1618
type CLIError struct {
1719
Code string // machine-readable: "auth_error", "not_found", "network_error"
@@ -131,7 +133,7 @@ func hintForAPICode(code string) string {
131133
case "voice_not_found":
132134
return "This voice does not exist. Retrying the same ID is unlikely to help. List voices: heygen voice list"
133135
case "insufficient_credit":
134-
return "Check your credit balance: heygen user me get. Purchase API credits: https://app.heygen.com/settings?nav=API"
136+
return "Check your credit balance: heygen user me get. Purchase API credits: " + APIKeySettingsURL
135137
case "invalid_parameter":
136138
return "Use --request-schema on the command to see expected fields"
137139
case "rate_limited":

0 commit comments

Comments
 (0)