{"record":{"id":"c4d554afbe3b841b","repo":"Yeachan-Heo/oh-my-codex","slug":"invalid-label-message","errorCode":null,"errorMessage":"Invalid ${label}: ${message}","messagePattern":"Invalid (.+?): (.+?)","errorType":"exception","errorClass":"UltragoalError","httpStatus":null,"severity":"error","filePath":"src/cli/ultragoal.ts","lineNumber":185,"sourceCode":"    `Required external decision: ${blocked.requiredExternalDecision ?? 'provide the missing authorization/credential, or explicitly choose a different unblock path'}.`,\n    'Do not run complete-goals --retry-failed again until that external state changes or the user explicitly authorizes an unblock path.',\n  ].join('\\n');\n}\n\nasync function parseCodexGoalJson(raw: string | undefined): Promise<unknown> {\n  if (!raw) return undefined;\n  return readCodexGoalSnapshotInput(raw, process.cwd());\n}\n\nasync function readJsonInput(raw: string | undefined, label = '--quality-gate-json'): Promise<unknown> {\n  if (!raw) return undefined;\n  try {\n    const trimmed = raw.trim();\n    if (trimmed.startsWith('{') || trimmed.startsWith('[')) return JSON.parse(trimmed);\n    return JSON.parse(await readFile(trimmed, 'utf-8'));\n  } catch (error) {\n    const message = error instanceof Error ? error.message : String(error);\n    throw new UltragoalError(`Invalid ${label}: ${message}`);\n  }\n}\n\nconst NATIVE_SUBAGENT_CAPACITY_BLOCKER_FILE = 'native-subagent-capacity-blocker.json';\n\nasync function readJsonIfExists<T>(path: string): Promise<T | null> {\n  try {\n    return JSON.parse(await readFile(path, 'utf-8')) as T;\n  } catch {\n    return null;\n  }\n}\n\nasync function resolveCodexGoalNativeSubagentSupport(cwd: string) {\n  const scope = await resolveRuntimeStateScope(cwd);\n  const [persistedSupportBlocker, persistedCapacityBlocker] = await Promise.all([\n    readJsonIfExists<Record<string, unknown>>(join(scope.baseStateDir, NATIVE_SUBAGENT_SUPPORT_BLOCKER_FILE)),\n    readJsonIfExists<Record<string, unknown>>(join(scope.baseStateDir, NATIVE_SUBAGENT_CAPACITY_BLOCKER_FILE)),","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/cli/ultragoal.ts#L167-L203","documentation":"readJsonInput parses values for flags like --directive-json and --after-json. It accepts either inline JSON (value starting with { or [) or a filesystem path to a JSON file. If neither parses — bad JSON syntax or an unreadable/missing file — it throws UltragoalError labeled with the flag name and the underlying parse error message.","triggerScenarios":"Passing `--after-json '{\"kind\":\"x\",}'` (trailing comma), `--directive-json missing.json` (ENOENT), or a path whose contents are not valid JSON; also permission errors reading the file.","commonSituations":"Hand-writing JSON on the shell with quoting mistakes; relative path resolved against an unexpected cwd; file generated by another tool with BOM or trailing text; single-quote heredoc issues.","solutions":["Validate the JSON with `jq . file.json` (or `echo '...' | jq .`) to find the syntax error, then fix it","If passing a path, confirm it exists and is readable from the CLI's working directory (use an absolute path)","For inline JSON prefer single-quoted shell strings to avoid interpolation breaking quotes"],"exampleFix":"# before\nomx ultragoal steer --after-json '{\"kind\":\"add_goal\",}'\n# Error: Invalid --after-json: Unexpected token } in JSON at position 18\n\n# after\nomx ultragoal steer --after-json '{\"kind\":\"add_goal\"}'","handlingStrategy":"validation","validationCode":"function parseJsonArg(raw: string, label: string): unknown {\n  const t = raw.trim();\n  const text = t.startsWith('{') || t.startsWith('[') ? t : readFileSync(t, 'utf-8');\n  return JSON.parse(text); // throws here first, with clearer context\n}\n// pre-validate before calling the CLI programmatically:\ntry { parseJsonArg(afterJson, '--after-json'); } catch { console.error('fix JSON before running omx'); }","typeGuard":null,"tryCatchPattern":"try { await ultragoalCommand(...) } catch (e) { if (e instanceof UltragoalError && e.message.startsWith('Invalid --')) showJsonDiagnostics(raw); else throw e; }","preventionTips":["Pipe candidate JSON through `jq .` before passing it","Use absolute paths for file inputs","Single-quote inline JSON in shells"],"tags":["cli","json","argument-parsing","ultragoal"],"backgroundTag":"invalid-json-input","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}