stablyai/orca · error · Error

Could not read keybindings file.

Error message

Could not read keybindings file.

What it means

Thrown by writeActivePlatformSection when readJsonDocument(path) cannot produce a document — the file is missing, empty, or unparseable. Writes must never overwrite a user-owned file that failed to parse (it could contain valid-but-unreadable data), so the operation aborts and surfaces readResult.error or this default message.

Source

Thrown at src/main/keybindings/keybinding-file.ts:396

    throw new Error(`Could not normalize legacy binding for "${failedActionIds.join('", "')}".`)
  }
  return { seeded: pins.length > 0, snapshot }
}

// Why: the one-shot seed migration and Settings writes must produce the same
// on-disk document shape; a single assembly path keeps them from drifting.
function writeActivePlatformSection(
  path: string,
  platform: NodeJS.Platform,
  fallbackCommonOverrides: KeybindingOverrides,
  mutateActivePlatform: (activePlatform: JsonObject) => void
): KeybindingFileSnapshot {
  const keybindingPlatform = getKeybindingPlatform(platform)
  const readResult = readJsonDocument(path)
  if (!readResult.document) {
    // Why: writes must never replace a user-owned file that could not be
    // parsed; callers surface the error (or retry the migration) after repair.
    throw new Error(readResult.error ?? 'Could not read keybindings file.')
  }
  const document = { ...readResult.document }
  const common = isJsonObject(document.keybindings)
    ? { ...document.keybindings }
    : { ...fallbackCommonOverrides }
  for (const rootKey of Object.keys(document)) {
    if (isKeybindingActionId(rootKey)) {
      delete document[rootKey]
    }
  }
  const platforms = isJsonObject(document.platforms) ? { ...document.platforms } : {}
  const activePlatform = isJsonObject(platforms[keybindingPlatform])
    ? { ...(platforms[keybindingPlatform] as JsonObject) }
    : {}
  mutateActivePlatform(activePlatform)

  document.version = FILE_VERSION
  document.keybindings = common

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Open the keybindings file and fix the JSON syntax error (validate with a JSON linter).
  2. If unrecoverable, back up then delete the file so Orca recreates defaults on next write.
  3. Run the migration/repair flow once the file parses.
  4. Ensure no external process is truncating the file mid-write.

Example fix

// before (file content)
{ "keybindings": {, } }
// after
{ "keybindings": {} }
Defensive patterns

Strategy: validation

Validate before calling

const readResult = readJsonDocument(path)
if (!readResult.document) await runKeybindingsFileRepair(path)

Type guard

function isReadableJsonDocument(path: string): boolean {
  return Boolean(readJsonDocument(path).document)
}

Try / catch

try { writeKeybindingOverride(path, platform, actionId, bindings) }
catch (e) { if (/Could not read keybindings file/.test(String((e as Error).message))) await repairOrResetKeybindingsFile(path); else throw e }

Prevention

When it happens

Trigger: The keybindings file was truncated, contains invalid JSON (trailing comma, comments), or was deleted while a write was queued. Any write path (override, conflict-resolution, migration) hits this guard first.

Common situations: Editor left the file partially written after a crash. Sync conflict produced a corrupt file. User hand-edited with a syntax error. Disk full during a prior write.

Related errors


AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12). Data as JSON: /api/errors/ca77b36b194d1e54. Report an issue: GitHub.