{"record":{"id":"c101e08352aca8e7","repo":"stablyai/orca","slug":"failed-to-load-path-basename-jsonpath-error","errorCode":null,"errorMessage":"Failed to load ${path.basename(jsonPath)}: ${error.message}","messagePattern":"Failed to load (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"config/scripts/locale-ko-key-overrides.mjs","lineNumber":14,"sourceCode":"import fs from 'node:fs'\nimport path from 'node:path'\n\n// Korean key-specific overrides (reviewed in full UI context: product names, git terms, and\n// labels MT mistranslated). Stored as a JSON data file — too many entries to inline under the\n// .mjs max-lines limit — and loaded here so the catalog scripts keep a single ko key-override source.\nconst jsonPath = path.join(import.meta.dirname, 'locale-ko-key-overrides.json')\n\nlet parsed\ntry {\n  parsed = JSON.parse(fs.readFileSync(jsonPath, 'utf8'))\n} catch (error) {\n  // Name the file: a bare JSON.parse SyntaxError doesn't say which file failed.\n  throw new Error(`Failed to load ${path.basename(jsonPath)}: ${error.message}`)\n}\n\nexport const KO_KEY_OVERRIDES = parsed\n","sourceCodeStart":1,"sourceCodeEnd":18,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/locale-ko-key-overrides.mjs#L1-L18","documentation":"locale-ko-key-overrides loads Korean key-specific translation overrides from a sibling JSON file (locale-ko-key-overrides.json). The raw JSON.parse is wrapped so that a parse failure names the offending file — a bare SyntaxError does not include the filename. The throw surfaces as a build/catalog-time failure importing the override catalog.","triggerScenarios":"The JSON file is missing (readFileSync throws ENOENT), or it contains a syntax error (trailing comma, unquoted key, stray character) so JSON.parse throws SyntaxError.","commonSituations":"Hand-editing the override JSON and leaving a syntax error, a merge conflict artifact in the file, the file not being committed/checked out in a shallow clone, or an encoding issue (BOM) from a Windows editor.","solutions":["Open locale-ko-key-overrides.json in an editor/JSON linter and fix the syntax error the message reports.","If the file is missing, restore it from git: git checkout HEAD -- config/scripts/locale-ko-key-overrides.json.","Validate with a JSON parser (node -e \"JSON.parse(require('fs').readFileSync('...'))\") to confirm the fix before re-running the catalog."],"exampleFix":"// before\ntry {\n  parsed = JSON.parse(fs.readFileSync(jsonPath, 'utf8'))\n} catch (error) {\n  throw new Error(`Failed to load ${path.basename(jsonPath)}: ${error.message}`)\n}\n\n// after (caller)\n// run once to locate the syntax error:\n//   node -e \"JSON.parse(require('fs').readFileSync('config/scripts/locale-ko-key-overrides.json','utf8'))\"\n// then fix the reported position in the JSON file.","handlingStrategy":"try-catch","validationCode":"const txt = fs.readFileSync(jsonPath, 'utf8')\nlet parsed\ntry { parsed = JSON.parse(txt) } catch (e) {\n  throw new Error(`${path.basename(jsonPath)} invalid at pos ${getPos(e)}: ${e.message}`)\n}","typeGuard":"const isParsableJson = (txt) => { try { JSON.parse(txt); return true } catch { return false } }","tryCatchPattern":"try {\n  import('./locale-ko-key-overrides.mjs')\n} catch (e) {\n  if (/Failed to load/.test(e.message)) { /* validate JSON, fix file, re-import */ }\n  throw e\n}","preventionTips":["Lint JSON files in CI (jsonschema or a JSON parser pre-commit hook).","Avoid hand-editing large JSON; regenerate from a source script when possible.","Ensure the file is committed and UTF-8 without BOM."],"tags":["json","file-io","locale","configuration"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}