Skip to content

Commit 932eca2

Browse files
mindfnclaude
andcommitted
fix: guard non-object target credentials.json in homedir migration
JSON.parse succeeds on null/string/number but `in` operator throws TypeError on non-objects. Normalize parsed value to {} when not a plain object. [宪宪/Opus-46🐾] Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0217075 commit 932eca2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/api/src/config/catalog-accounts.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,10 @@ function migrateHomedirCredentials(projectRoot?: string): void {
396396
let targetCreds: Record<string, unknown> = {};
397397
if (existsSync(targetCredPath)) {
398398
try {
399-
targetCreds = JSON.parse(readFileSync(targetCredPath, 'utf-8'));
399+
const parsed = JSON.parse(readFileSync(targetCredPath, 'utf-8'));
400+
if (typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed)) {
401+
targetCreds = parsed;
402+
}
400403
} catch {
401404
targetCreds = {};
402405
}

0 commit comments

Comments
 (0)