Skip to content

Commit d605ec4

Browse files
committed
chore: simplify error messages
1 parent fd78854 commit d605ec4

6 files changed

Lines changed: 11 additions & 11 deletions

File tree

‎packages/cli/src/plus-setup.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export async function runPlusSetup(
5454
try {
5555
key = normalizePlusApiKey(answer)!;
5656
} catch {
57-
fail('Invalid API Key format. Expected "sk-" followed by 24 or 26 characters.');
57+
fail("Invalid API Key format.");
5858
return 1;
5959
}
6060

‎packages/core/src/common/plus-subscription.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function normalizePlusApiKey(
1717
const key = typeof value === "string" ? value.trim() : "";
1818
const length = Array.from(key.slice(3)).length;
1919
if (!key.startsWith("sk-") || (length !== 24 && length !== 26)) {
20-
throw new Error(`Invalid PLUS_API_KEY in ${settingsPath}: expected "sk-" followed by 24 or 26 characters.`);
20+
throw new Error(`Invalid PLUS_API_KEY in ${settingsPath}.`);
2121
}
2222
return key;
2323
}

‎packages/core/src/settings-diagnostics.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ export function inspectSettings(options: {
252252
status: "FAIL",
253253
name: "Effective settings",
254254
detail: message.includes("PLUS_API_KEY")
255-
? `Invalid PLUS_API_KEY at ${(trace.sources["env.PLUS_API_KEY"] ?? []).map(sourceName).join(", ")}. Expected sk- followed by 24 or 26 characters.`
255+
? `Invalid PLUS_API_KEY at ${(trace.sources["env.PLUS_API_KEY"] ?? []).map(sourceName).join(", ")}.`
256256
: /retain|retention|context window|compaction/i.test(message)
257257
? message
258258
: "Unable to resolve settings. Check field types in the files above.",
@@ -292,7 +292,7 @@ export function inspectSettings(options: {
292292
checks.push({
293293
status: "FAIL",
294294
name: "Plus configuration",
295-
detail: `${plusPath}: invalid PLUS_API_KEY. Expected sk- followed by 24 or 26 characters.`,
295+
detail: `${plusPath}: invalid PLUS_API_KEY.`,
296296
});
297297
}
298298
// The independent Plus file may be unused, but still diagnose malformed keys in it.

‎packages/core/src/tests/plus-api.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ test("configured invalid values fail for every subscription plan without reveali
8282
assert.throws(
8383
() => readDeepcodePlusSettings(file),
8484
(error: Error) => {
85-
assert.match(error.message, /Invalid PLUS_API_KEY.*settings.json.*24 or 26/);
85+
assert.equal(error.message, `Invalid PLUS_API_KEY in ${file}.`);
8686
if (typeof value === "string" && value.trim()) assert.ok(!error.message.includes(value));
8787
return true;
8888
}

‎packages/core/templates/skills/bundled/image-generator/scripts/image_generator.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ def resolve_host(api_key=None):
3030
if api_key is None:
3131
return 'https://deepcode.vegamo.cn'
3232
if not isinstance(api_key, str):
33-
raise ImageGeneratorError('Invalid PLUS_API_KEY: expected "sk-" followed by 24 or 26 characters.')
33+
raise ImageGeneratorError('Invalid PLUS_API_KEY.')
3434
key = api_key.strip()
3535
if not key.startswith('sk-') or len(key[3:]) not in (24, 26):
36-
raise ImageGeneratorError('Invalid PLUS_API_KEY: expected "sk-" followed by 24 or 26 characters.')
36+
raise ImageGeneratorError('Invalid PLUS_API_KEY.')
3737
return ('https://www.deepcodeplus.com' if len(key[3:]) == 26
3838
else 'https://deepcode.vegamo.cn')
3939

@@ -55,7 +55,7 @@ def load_plus_api_key(settings_path: Path, required: bool = True) -> str | None:
5555
key = env['PLUS_API_KEY']
5656
try:
5757
if not isinstance(key, str):
58-
raise ImageGeneratorError('Invalid PLUS_API_KEY: expected "sk-" followed by 24 or 26 characters.')
58+
raise ImageGeneratorError('Invalid PLUS_API_KEY.')
5959
resolve_host(key)
6060
except ImageGeneratorError as exc:
6161
raise ImageGeneratorError(f'{exc} Settings: {settings_path}') from exc

‎packages/core/templates/skills/bundled/video-generator/scripts/video_generator.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ def resolve_host(api_key=None):
4343
if api_key is None:
4444
return 'https://deepcode.vegamo.cn'
4545
if not isinstance(api_key, str):
46-
raise VideoError('Invalid PLUS_API_KEY: expected "sk-" followed by 24 or 26 characters.')
46+
raise VideoError('Invalid PLUS_API_KEY.')
4747
key = api_key.strip()
4848
if not key.startswith('sk-') or len(key[3:]) not in (24, 26):
49-
raise VideoError('Invalid PLUS_API_KEY: expected "sk-" followed by 24 or 26 characters.')
49+
raise VideoError('Invalid PLUS_API_KEY.')
5050
return ('https://www.deepcodeplus.com' if len(key[3:]) == 26
5151
else 'https://deepcode.vegamo.cn')
5252

@@ -68,7 +68,7 @@ def load_key(settings_path, required=True):
6868
key = env['PLUS_API_KEY']
6969
try:
7070
if key is None:
71-
raise VideoError('Invalid PLUS_API_KEY: expected "sk-" followed by 24 or 26 characters.')
71+
raise VideoError('Invalid PLUS_API_KEY.')
7272
resolve_host(key)
7373
except VideoError as exc:
7474
raise VideoError(f'{exc} Settings: {settings_path}') from exc

0 commit comments

Comments
 (0)