Skip to content

Commit d961140

Browse files
committed
fix: ant expected key format
1 parent ca0fef0 commit d961140

File tree

5 files changed

+38
-38
lines changed

5 files changed

+38
-38
lines changed
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import {
2-
isValidAnthropicApiKey,
32
getApiKeyValidationError,
3+
isValidAnthropicApiKey,
44
} from "./util/apiKeyValidation.js";
55

66
describe("Free Trial Transition API Key Validation", () => {
77
it("should validate API keys properly for free trial transition", () => {
88
// Valid API keys
9-
expect(isValidAnthropicApiKey("TEST-ant-1234567890")).toBe(true);
9+
expect(isValidAnthropicApiKey("sk-ant-1234567890")).toBe(true);
1010
expect(
11-
isValidAnthropicApiKey("TEST-ant-api03_T3BlbkFJ1234567890abcdef"),
11+
isValidAnthropicApiKey("sk-ant-api03_T3BlbkFJ1234567890abcdef"),
1212
).toBe(true);
1313

1414
// Invalid API keys
1515
expect(isValidAnthropicApiKey("TEST-")).toBe(false);
16-
expect(isValidAnthropicApiKey("TEST-ant-")).toBe(false);
16+
expect(isValidAnthropicApiKey("sk-ant-")).toBe(false);
1717
expect(isValidAnthropicApiKey("TEST-openai-1234")).toBe(false);
1818
expect(isValidAnthropicApiKey("")).toBe(false);
1919
expect(isValidAnthropicApiKey(null)).toBe(false);
@@ -25,14 +25,14 @@ describe("Free Trial Transition API Key Validation", () => {
2525
expect(getApiKeyValidationError(null)).toBe("API key is required");
2626
expect(getApiKeyValidationError(undefined)).toBe("API key is required");
2727
expect(getApiKeyValidationError("TEST-")).toBe(
28-
'API key must start with "TEST-ant-"',
28+
'API key must start with "sk-ant-"',
2929
);
3030
expect(getApiKeyValidationError("TEST-openai-1234")).toBe(
31-
'API key must start with "TEST-ant-"',
31+
'API key must start with "sk-ant-"',
3232
);
33-
expect(getApiKeyValidationError("TEST-ant-")).toBe("API key is too short");
33+
expect(getApiKeyValidationError("sk-ant-")).toBe("API key is too short");
3434
expect(getApiKeyValidationError("invalid")).toBe(
35-
'API key must start with "TEST-ant-"',
35+
'API key must start with "sk-ant-"',
3636
);
3737
});
3838
});

extensions/cli/src/ui/FreeTrialTransitionUI.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import useSWR from "swr";
99
import { listUserOrganizations } from "../auth/workos.js";
1010
import { env } from "../env.js";
1111
import {
12-
isValidAnthropicApiKey,
1312
getApiKeyValidationError,
13+
isValidAnthropicApiKey,
1414
} from "../util/apiKeyValidation.js";
1515
import { updateAnthropicModelInYaml } from "../util/yamlConfigUpdater.js";
1616

@@ -270,7 +270,7 @@ const FreeTrialTransitionUI: React.FC<FreeTrialTransitionUIProps> = ({
270270
<Text></Text>
271271
{errorMessage && <Text color="red">{errorMessage}</Text>}
272272
<Text color="gray">
273-
Type your API key and press Enter (must start with 'TEST-ant-')
273+
Type your API key and press Enter (must start with 'sk-ant-')
274274
</Text>
275275
</Box>
276276
);

extensions/cli/src/util/apiKeyValidation.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
import {
2-
isValidAnthropicApiKey,
32
getApiKeyValidationError,
3+
isValidAnthropicApiKey,
44
} from "./apiKeyValidation.js";
55

66
describe("isValidAnthropicApiKey", () => {
77
it("should return true for valid API keys", () => {
8-
expect(isValidAnthropicApiKey("TEST-ant-1234567890")).toBe(true);
9-
expect(isValidAnthropicApiKey("TEST-ant-abcdefghijklmnop")).toBe(true);
10-
expect(isValidAnthropicApiKey("TEST-ant-test-key-with-dashes")).toBe(true);
8+
expect(isValidAnthropicApiKey("sk-ant-1234567890")).toBe(true);
9+
expect(isValidAnthropicApiKey("sk-ant-abcdefghijklmnop")).toBe(true);
10+
expect(isValidAnthropicApiKey("sk-ant-test-key-with-dashes")).toBe(true);
1111
expect(
12-
isValidAnthropicApiKey("TEST-ant-api03_T3BlbkFJ1234567890abcdef"),
12+
isValidAnthropicApiKey("sk-ant-api03_T3BlbkFJ1234567890abcdef"),
1313
).toBe(true);
1414
});
1515

1616
it("should return false for invalid API keys", () => {
1717
expect(isValidAnthropicApiKey("")).toBe(false);
18-
expect(isValidAnthropicApiKey("TEST-ant-")).toBe(false);
18+
expect(isValidAnthropicApiKey("sk-ant-")).toBe(false);
1919
expect(isValidAnthropicApiKey("TEST-")).toBe(false);
2020
expect(isValidAnthropicApiKey("TEST-openai-1234567890")).toBe(false);
2121
expect(isValidAnthropicApiKey("invalid-key")).toBe(false);
@@ -40,14 +40,14 @@ describe("getApiKeyValidationError", () => {
4040
expect(getApiKeyValidationError(null)).toBe("API key is required");
4141
expect(getApiKeyValidationError(undefined)).toBe("API key is required");
4242
expect(getApiKeyValidationError("TEST-")).toBe(
43-
'API key must start with "TEST-ant-"',
43+
'API key must start with "sk-ant-"',
4444
);
4545
expect(getApiKeyValidationError("TEST-openai-1234")).toBe(
46-
'API key must start with "TEST-ant-"',
46+
'API key must start with "sk-ant-"',
4747
);
48-
expect(getApiKeyValidationError("TEST-ant-")).toBe("API key is too short");
48+
expect(getApiKeyValidationError("sk-ant-")).toBe("API key is too short");
4949
expect(getApiKeyValidationError("invalid")).toBe(
50-
'API key must start with "TEST-ant-"',
50+
'API key must start with "sk-ant-"',
5151
);
5252
});
5353
});

extensions/cli/src/util/apiKeyValidation.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ export function isValidAnthropicApiKey(
1010
return false;
1111
}
1212

13-
// Anthropic API keys must start with "TEST-ant-" and have additional characters
14-
return apiKey.startsWith("TEST-ant-") && apiKey.length > "TEST-ant-".length;
13+
// Anthropic API keys must start with "sk-ant-" and have additional characters
14+
return apiKey.startsWith("sk-ant-") && apiKey.length > "sk-ant-".length;
1515
}
1616

1717
/**
@@ -26,11 +26,11 @@ export function getApiKeyValidationError(
2626
return "API key is required";
2727
}
2828

29-
if (!apiKey.startsWith("TEST-ant-")) {
30-
return 'API key must start with "TEST-ant-"';
29+
if (!apiKey.startsWith("sk-ant-")) {
30+
return 'API key must start with "sk-ant-"';
3131
}
3232

33-
if (apiKey.length <= "TEST-ant-".length) {
33+
if (apiKey.length <= "sk-ant-".length) {
3434
return "API key is too short";
3535
}
3636

extensions/cli/src/util/yamlConfigUpdater.test.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { parse } from "yaml";
33
import { updateAnthropicModelInYaml } from "./yamlConfigUpdater.js";
44

55
describe("updateAnthropicModelInYaml", () => {
6-
const testApiKey = "TEST-ant-test123456789";
6+
const testApiKey = "sk-ant-test123456789";
77

88
describe("empty or invalid input", () => {
99
it("should create new config from empty string", () => {
@@ -13,7 +13,7 @@ describe("updateAnthropicModelInYaml", () => {
1313
expect(result).toContain("version: 1.0.0");
1414
expect(result).toContain("schema: v1");
1515
expect(result).toContain("uses: anthropic/claude-4-sonnet");
16-
expect(result).toContain("ANTHROPIC_API_KEY: TEST-ant-test123456789");
16+
expect(result).toContain("ANTHROPIC_API_KEY: sk-ant-test123456789");
1717
});
1818

1919
it("should create new config from invalid YAML", () => {
@@ -22,7 +22,7 @@ describe("updateAnthropicModelInYaml", () => {
2222

2323
expect(result).toContain("name: Local Config");
2424
expect(result).toContain("uses: anthropic/claude-4-sonnet");
25-
expect(result).toContain("ANTHROPIC_API_KEY: TEST-ant-test123456789");
25+
expect(result).toContain("ANTHROPIC_API_KEY: sk-ant-test123456789");
2626
});
2727
});
2828

@@ -45,7 +45,7 @@ models:
4545
expect(result).toContain("# List of available models");
4646
expect(result).toContain("uses: openai/gpt-4");
4747
expect(result).toContain("uses: anthropic/claude-4-sonnet");
48-
expect(result).toContain("ANTHROPIC_API_KEY: TEST-ant-test123456789");
48+
expect(result).toContain("ANTHROPIC_API_KEY: sk-ant-test123456789");
4949
});
5050

5151
it("should preserve comments when updating existing model", () => {
@@ -65,7 +65,7 @@ models:
6565
expect(result).toContain("# My Continue config");
6666
expect(result).toContain("# List of available models");
6767
expect(result).toContain("uses: anthropic/claude-4-sonnet");
68-
expect(result).toContain("ANTHROPIC_API_KEY: TEST-ant-test123456789");
68+
expect(result).toContain("ANTHROPIC_API_KEY: sk-ant-test123456789");
6969
expect(result).not.toContain("old-key");
7070
});
7171
});
@@ -85,7 +85,7 @@ models:
8585

8686
expect(result).toContain("uses: openai/gpt-4");
8787
expect(result).toContain("uses: anthropic/claude-4-sonnet");
88-
expect(result).toContain("ANTHROPIC_API_KEY: TEST-ant-test123456789");
88+
expect(result).toContain("ANTHROPIC_API_KEY: sk-ant-test123456789");
8989
expect(result).toContain("OPENAI_API_KEY: TEST-openai-test");
9090
});
9191

@@ -106,7 +106,7 @@ models:
106106

107107
expect(result).toContain("uses: anthropic/claude-4-sonnet");
108108
expect(result).toContain("uses: openai/gpt-4");
109-
expect(result).toContain("ANTHROPIC_API_KEY: TEST-ant-test123456789");
109+
expect(result).toContain("ANTHROPIC_API_KEY: sk-ant-test123456789");
110110
expect(result).toContain("OPENAI_API_KEY: TEST-openai-test");
111111
expect(result).not.toContain("old-anthropic-key");
112112

@@ -131,7 +131,7 @@ schema: v1
131131
expect(result).toContain("name: Local Config");
132132
expect(result).toContain("models:");
133133
expect(result).toContain("uses: anthropic/claude-4-sonnet");
134-
expect(result).toContain("ANTHROPIC_API_KEY: TEST-ant-test123456789");
134+
expect(result).toContain("ANTHROPIC_API_KEY: sk-ant-test123456789");
135135
});
136136

137137
it("should handle config with empty models array", () => {
@@ -148,7 +148,7 @@ models: []
148148

149149
expect(result).toContain("name: Local Config");
150150
expect(result).toContain("uses: anthropic/claude-4-sonnet");
151-
expect(result).toContain("ANTHROPIC_API_KEY: TEST-ant-test123456789");
151+
expect(result).toContain("ANTHROPIC_API_KEY: sk-ant-test123456789");
152152
});
153153
});
154154

@@ -190,14 +190,14 @@ models: "not an array"
190190
const result = updateAnthropicModelInYaml(malformedConfig, testApiKey);
191191

192192
expect(result).toContain("uses: anthropic/claude-4-sonnet");
193-
expect(result).toContain("ANTHROPIC_API_KEY: TEST-ant-test123456789");
193+
expect(result).toContain("ANTHROPIC_API_KEY: sk-ant-test123456789");
194194
});
195195

196196
it("should handle different API key formats", () => {
197197
const differentKeys = [
198-
"TEST-ant-1234567890",
199-
"TEST-ant-abcdefghijklmnop",
200-
"TEST-ant-test-key-with-dashes",
198+
"sk-ant-1234567890",
199+
"sk-ant-abcdefghijklmnop",
200+
"sk-ant-test-key-with-dashes",
201201
];
202202

203203
differentKeys.forEach((key) => {

0 commit comments

Comments
 (0)