Yeachan-Heo/oh-my-codex · error · Error

Unsupported sandbox.md frontmatter line: ${trimmed}

Error message

Unsupported sandbox.md frontmatter line: ${trimmed}

What it means

parseSimpleYamlFrontmatter throws when a frontmatter line is neither a section header ('key:'), a nested 'key: value' pair, nor matches the /^([A-Za-z0-9_-]+):\s*(.+)\s*$/ shape. The parser supports only a tiny YAML subset, so list items, comments, multiline strings, or keys with unsupported characters make the line unparseable and it throws with the offending line included.

Source

Thrown at src/autoresearch/contracts.ts:111

function parseSimpleYamlFrontmatter(frontmatter: string): Record<string, unknown> {
  const result: Record<string, unknown> = {};
  let currentSection: string | null = null;

  for (const rawLine of frontmatter.split(/\r?\n/)) {
    const line = rawLine.replace(/\t/g, '  ');
    const trimmed = line.trim();
    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;

View on GitHub (pinned to 3ad79a8a6f)

Solutions

  1. Rewrite the offending line as 'key: value' with an alphanumeric/underscore/hyphen key.
  2. Remove list items, comments, and multi-line YAML constructs from sandbox.md frontmatter.
  3. Keep nesting to exactly one level under a section header like 'evaluator:'.
  4. Check the exact line quoted in the error message and fix or delete it.

Example fix

# before (sandbox.md frontmatter)
evaluator:
  command: ./run.sh
  # timeout in seconds
  format: json

# after
evaluator:
  command: ./run.sh
  format: json
Defensive patterns

Strategy: validation

Validate before calling

const FRONTMATTER_LINE = /^(?:[A-Za-z0-9_-]+:\s*(?:\S.*)?|[ \t]+[A-Za-z0-9_-]+:\s*.+)$/;

function frontmatterLinesSupported(frontmatter: string): boolean {
  return frontmatter.split(/\r?\n/).filter(l => l.trim()).every(l => FRONTMATTER_LINE.test(l));
}

Type guard

const isSimpleYamlLine = (line: string): boolean =>
  /^[A-Za-z0-9_-]+:(\s+.*)?$/.test(line) || /^[ \t]+[A-Za-z0-9_-]+:\s+.+$/.test(line);

Try / catch

try {
  parseSandboxContract(content);
} catch (err) {
  if ((err as Error).message.startsWith('Unsupported sandbox.md frontmatter line')) {
    // the message quotes the exact offending line; simplify it to 'key: value'
  }
  throw err;
}

Prevention

When it happens

Trigger: A sandbox.md frontmatter line like '- item', 'key: [a, b]', '# comment', 'key:', with unsupported characters in the key (spaces, dots), or a value line without a colon — anything the simple regex cannot match after failing the section/nested checks.

Common situations: Copying richer YAML from elsewhere (anchors, lists, quotes spanning lines) into sandbox.md; adding comments with '#'; using keys with dots or spaces expecting full YAML support.

Related errors


AI-assisted analysis of Yeachan-Heo/oh-my-codex@3ad79a8a6f (2026-08-27). Data as JSON: /api/errors/62cfde582a544efd. Report an issue: GitHub.