musistudio/claude-code-router · error · Error

Claude Code settings file is not valid JSON: ${file}. ${form

Error message

Claude Code settings file is not valid JSON: ${file}. ${formatError(error)}

What it means

Error "Claude Code settings file is not valid JSON: ${file}. ${formatError(error)}" thrown in musistudio/claude-code-router.

Source

Thrown at packages/core/src/profiles/service.ts:2680

    const parsed = JSON.parse(readFileSync(file, "utf8")) as unknown;
    return isRecord(parsed) ? parsed : {};
  } catch {
    return {};
  }
}

function readClaudeCodeSettingsObject(file: string): Record<string, unknown> {
  if (!existsSync(file)) {
    return {};
  }
  try {
    const parsed = JSON.parse(readFileSync(file, "utf8")) as unknown;
    if (isRecord(parsed)) {
      return parsed;
    }
    throw new Error("root value is not an object");
  } catch (error) {
    throw new Error(`Claude Code settings file is not valid JSON: ${file}. ${formatError(error)}`);
  }
}

function writeClaudeCodeSettingsIfManagedChanged(
  file: string,
  settings: Record<string, unknown>,
  nextSettings: Record<string, unknown>,
  managedEnvKeys: Set<string>
): { backupFile?: string; changed: boolean } {
  if (!claudeCodeSettingsManagedFieldsChanged(settings, nextSettings, managedEnvKeys)) {
    chmodFileIfRequested(file, privateFileMode);
    return { changed: false };
  }
  return writeFileWithBackup(file, `${JSON.stringify(nextSettings, null, 2)}\n`, { mode: privateFileMode });
}

function claudeCodeSettingsManagedFieldsChanged(
  settings: Record<string, unknown>,

View on GitHub (pinned to 99f24806c6)

When it happens

Trigger: Thrown at packages/core/src/profiles/service.ts:2680 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of musistudio/claude-code-router@99f24806c6 (2026-08-27). Data as JSON: /api/errors/8cd12378d2835f09. Report an issue: GitHub.