{"record":{"id":"b7aaa3aac54fbe8e","repo":"Yeachan-Heo/oh-my-codex","slug":"nested-sandbox-md-frontmatter-key-requires-a-paren","errorCode":null,"errorMessage":"Nested sandbox.md frontmatter key requires a parent section: ${trimmed}","messagePattern":"Nested sandbox\\.md frontmatter key requires a parent section: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/autoresearch/contracts.ts","lineNumber":118,"sourceCode":"    if (!trimmed || trimmed.startsWith('#')) continue;\n\n    const sectionMatch = /^([A-Za-z0-9_-]+):\\s*$/.exec(trimmed);\n    if (sectionMatch) {\n      currentSection = sectionMatch[1];\n      result[currentSection] = {};\n      continue;\n    }\n\n    const nestedMatch = /^([A-Za-z0-9_-]+):\\s*(.+)\\s*$/.exec(trimmed);\n    if (!nestedMatch) {\n      throw contractError(`Unsupported sandbox.md frontmatter line: ${trimmed}`);\n    }\n\n    const [, key, rawValue] = nestedMatch;\n    const value = rawValue.replace(/^['\"]|['\"]$/g, '');\n    if (line.startsWith(' ') || line.startsWith('\\t')) {\n      if (!currentSection) {\n        throw contractError(`Nested sandbox.md frontmatter key requires a parent section: ${trimmed}`);\n      }\n      const section = result[currentSection];\n      if (!section || typeof section !== 'object' || Array.isArray(section)) {\n        throw contractError(`Invalid sandbox.md frontmatter section: ${currentSection}`);\n      }\n      (section as Record<string, unknown>)[key] = value;\n      continue;\n    }\n\n    result[key] = value;\n    currentSection = null;\n  }\n\n  return result;\n}\n\nfunction parseKeepPolicy(raw: unknown): AutoresearchKeepPolicy | undefined {\n  if (raw === undefined) return undefined;","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/autoresearch/contracts.ts#L100-L136","documentation":"parseSimpleYamlFrontmatter throws when an indented 'key: value' line appears before any section header has been declared. The parser only supports one level of nesting, and nested keys must follow a top-level 'section:' line that sets currentSection; otherwise there is no parent to attach the key to.","triggerScenarios":"Frontmatter where the first line(s) are indented key/value pairs, e.g. content starting with '  command: ./run.sh' before an 'evaluator:' header, or a blank-interrupted structure where the section context is lost.","commonSituations":"Manually reordering YAML so nested keys land above their section; deleting the 'evaluator:' line while keeping its children; pasting YAML with leading indentation on the first key.","solutions":["Ensure every indented key is preceded by an unindented section header line like 'evaluator:'.","Remove stray leading indentation from top-level keys.","Rebuild the frontmatter from the canonical evaluator template."],"exampleFix":"# before\n  command: ./run.sh\nevaluator:\n  format: json\n\n# after\nevaluator:\n  command: ./run.sh\n  format: json","handlingStrategy":"validation","validationCode":"function nestingHasParent(frontmatter: string): boolean {\n  let hasSection = false;\n  for (const line of frontmatter.split(/\\r?\\n/)) {\n    if (!line.trim()) continue;\n    if (/^[ \\t]/.test(line)) { if (!hasSection) return false; }\n    else if (/^[A-Za-z0-9_-]+:\\s*$/.test(line)) { hasSection = true; }\n  }\n  return true;\n}","typeGuard":null,"tryCatchPattern":"try {\n  parseSandboxContract(content);\n} catch (err) {\n  if ((err as Error).message.includes('requires a parent section')) {\n    // move the indented key under a section header like 'evaluator:'\n  }\n  throw err;\n}","preventionTips":["Always declare an unindented 'evaluator:' header before indented keys.","Never indent the first key of the frontmatter.","Use a YAML-aware editor with consistent indentation."],"tags":["yaml","frontmatter","sandbox-md","indentation"],"backgroundTag":"yaml-indentation-error","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}