{"record":{"id":"071977ed462d5738","repo":"stablyai/orca","slug":"use-a-string-array-or-null","errorCode":null,"errorMessage":"Use a string array or null.","messagePattern":"Use a string array or null\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/keybindings/keybinding-file.ts","lineNumber":120,"sourceCode":"    if (!value.every((item) => typeof item === 'string')) {\n      return { ok: false, error: 'Use a string, string array, null, or false.' }\n    }\n    const normalized = normalizeKeybindingArrayForAction(actionId, value)\n    return Array.isArray(normalized)\n      ? { ok: true, value: normalized }\n      : normalized.ok\n        ? { ok: true, value: [normalized.value] }\n        : normalized\n  }\n  return { ok: false, error: 'Use a string, string array, null, or false.' }\n}\n\nfunction normalizeWriteBindingValue(actionId: KeybindingActionId, value: unknown): string[] | null {\n  if (value === null) {\n    return null\n  }\n  if (!Array.isArray(value) || !value.every((binding) => typeof binding === 'string')) {\n    throw new Error('Use a string array or null.')\n  }\n  const normalized = normalizeKeybindingArrayForAction(actionId, value)\n  if (!Array.isArray(normalized)) {\n    throw new Error(normalized.ok ? 'Unable to parse shortcut.' : normalized.error)\n  }\n  return normalized\n}\n\nfunction parseBindingSection(\n  value: unknown,\n  section: string,\n  diagnostics: KeybindingFileDiagnostic[],\n  options: { skipRootKeys?: boolean } = {}\n): KeybindingOverrides {\n  if (value === undefined) {\n    return {}\n  }\n  if (!isJsonObject(value)) {","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/keybindings/keybinding-file.ts#L102-L138","documentation":"Thrown by normalizeWriteBindingValue when the value passed to a keybinding write is not null and not an array of strings. This is the strict write path (Settings UI): it accepts only string[] or null, unlike the read/parse path which also tolerates a single string, false, etc.","triggerScenarios":"writeKeybindingOverride is called with a non-null non-array value (number, object, boolean, or an array containing non-strings like numbers/null). Typical when a programmatic caller reuses the looser read schema for a write.","commonSituations":"Settings migration code feeding parsed JSON values directly into the write API. A custom UI control emitting a single string instead of ['cmd+k']. JSON config hand-edited to a non-array.","solutions":["Pass bindings as string[] (e.g. ['Cmd+K']) or null to clear.","If you have a single string, wrap it: [binding] before calling write.","Validate Array.isArray(v) && v.every(x => typeof x === 'string') before the write."],"exampleFix":"// before\nwriteKeybindingOverride(path, platform, actionId, 'Cmd+K')\n// after\nwriteKeybindingOverride(path, platform, actionId, ['Cmd+K'])","handlingStrategy":"validation","validationCode":"function isValidWriteBindings(v: unknown): v is string[] | null {\n  return v === null || (Array.isArray(v) && v.every((b) => typeof b === 'string'))\n}\nif (!isValidWriteBindings(value)) throw new Error('pass string[] or null')","typeGuard":"function isStringArrayOrNull(v: unknown): v is string[] | null {\n  return v === null || (Array.isArray(v) && v.every((b) => typeof b === 'string'))\n}","tryCatchPattern":"try { writeKeybindingOverride(path, platform, actionId, bindings) }\ncatch (e) { if (/string array or null/.test(String((e as Error).message))) notifyInvalidBinding(); else throw e }","preventionTips":["Always pass string[] (or null to clear) to the write API.","Wrap single strings in an array before writing.","Validate array-of-string before feeding parsed JSON into writes."],"tags":["keybindings","validation","write"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}