Yeachan-Heo/oh-my-codex · error · Error
Nested sandbox.md frontmatter key requires a parent section:
Error message
Nested sandbox.md frontmatter key requires a parent section: ${trimmed} What it means
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.
Source
Thrown at src/autoresearch/contracts.ts:118
if (!trimmed || trimmed.startsWith('#')) continue;
const sectionMatch = /^([A-Za-z0-9_-]+):\s*$/.exec(trimmed);
if (sectionMatch) {
currentSection = sectionMatch[1];
result[currentSection] = {};
continue;
}
const nestedMatch = /^([A-Za-z0-9_-]+):\s*(.+)\s*$/.exec(trimmed);
if (!nestedMatch) {
throw contractError(`Unsupported sandbox.md frontmatter line: ${trimmed}`);
}
const [, key, rawValue] = nestedMatch;
const value = rawValue.replace(/^['"]|['"]$/g, '');
if (line.startsWith(' ') || line.startsWith('\t')) {
if (!currentSection) {
throw contractError(`Nested sandbox.md frontmatter key requires a parent section: ${trimmed}`);
}
const section = result[currentSection];
if (!section || typeof section !== 'object' || Array.isArray(section)) {
throw contractError(`Invalid sandbox.md frontmatter section: ${currentSection}`);
}
(section as Record<string, unknown>)[key] = value;
continue;
}
result[key] = value;
currentSection = null;
}
return result;
}
function parseKeepPolicy(raw: unknown): AutoresearchKeepPolicy | undefined {
if (raw === undefined) return undefined;View on GitHub (pinned to 3ad79a8a6f)
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.
Example fix
# before command: ./run.sh evaluator: format: json # after evaluator: command: ./run.sh format: json
Defensive patterns
Strategy: validation
Validate before calling
function nestingHasParent(frontmatter: string): boolean {
let hasSection = false;
for (const line of frontmatter.split(/\r?\n/)) {
if (!line.trim()) continue;
if (/^[ \t]/.test(line)) { if (!hasSection) return false; }
else if (/^[A-Za-z0-9_-]+:\s*$/.test(line)) { hasSection = true; }
}
return true;
} Try / catch
try {
parseSandboxContract(content);
} catch (err) {
if ((err as Error).message.includes('requires a parent section')) {
// move the indented key under a section header like 'evaluator:'
}
throw err;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- sandbox.md must start with YAML frontmatter containing evalu
- Unsupported sandbox.md frontmatter line: ${trimmed}
- Invalid sandbox.md frontmatter section: ${currentSection}
- sandbox.md frontmatter evaluator.keep_policy must be a strin
- ${filePath} frontmatter "${key}" must not be empty
AI-assisted analysis of Yeachan-Heo/oh-my-codex@3ad79a8a6f (2026-08-27).
Data as JSON: /api/errors/b7aaa3aac54fbe8e.
Report an issue: GitHub.