{"record":{"id":"4103bdd51fb2bd3d","repo":"JuliusBrussee/caveman","slug":"label-lineno-nesting-deeper-than-two-levels","errorCode":null,"errorMessage":"${label}:${lineNo}: nesting deeper than two levels is not supported","messagePattern":"(.+?):(.+?): nesting deeper than two levels is not supported","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/generate-agent-catalog.mjs","lineNumber":99,"sourceCode":"        blockKey = null;\n        row[entry.key] = entry.value;\n      }\n      continue;\n    }\n    if (indent === 4) {\n      if (blockKey === null) throw new Error(`${label}:${lineNo}: nested line without an open block`);\n      if (dash) {\n        if (row[blockKey] === undefined) row[blockKey] = [];\n        if (!Array.isArray(row[blockKey])) throw new Error(`${label}:${lineNo}: \"${blockKey}\" mixes map and sequence entries`);\n        row[blockKey].push(rest);\n        continue;\n      }\n      if (row[blockKey] === undefined) row[blockKey] = {};\n      if (Array.isArray(row[blockKey]) || typeof row[blockKey] !== \"object\") {\n        throw new Error(`${label}:${lineNo}: \"${blockKey}\" mixes map and sequence entries`);\n      }\n      const entry = splitKeyValue(rest, label, lineNo);\n      if (entry.value === undefined) throw new Error(`${label}:${lineNo}: nesting deeper than two levels is not supported`);\n      if (Object.prototype.hasOwnProperty.call(row[blockKey], entry.key)) {\n        throw new Error(`${label}:${lineNo}: duplicate key \"${blockKey}.${entry.key}\"`);\n      }\n      row[blockKey][entry.key] = entry.value;\n      continue;\n    }\n    throw new Error(`${label}:${lineNo}: unexpected indent of ${indent} spaces`);\n  }\n  return rows;\n}\n\nfunction splitKeyValue(text, label, lineNo) {\n  const match = /^([A-Za-z_][A-Za-z0-9_]*):(?: (.*))?$/.exec(text);\n  if (match === null) throw new Error(`${label}:${lineNo}: cannot read \"${text}\" as a \"key: value\" pair`);\n  return { key: match[1], value: match[2] === undefined ? undefined : scalar(match[2], label, lineNo) };\n}\n\nfunction scalar(text, label, lineNo) {","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/scripts/generate-agent-catalog.mjs#L81-L117","documentation":"Thrown by the catalog parser when an indent-4 line inside a map block is itself a valueless key (\"    key:\" with no inline value). The parser supports exactly two nesting levels; a key that opens a third level has no representation in the generated catalog, so it is rejected rather than silently dropped.","triggerScenarios":"Writing a block key at indent 2 whose children are also block headers, e.g. \"  limits:\" then \"    context:\" intended to be followed by indent-6 values — the indent-4 \"context:\" line with no value triggers the error immediately.","commonSituations":"Porting a deeply nested YAML config (k8s-style) into the catalog format; organically growing config depth over time; pasting a nested fragment without flattening it.","solutions":["Flatten to two levels: combine the keys, e.g. \"  limits:\" + \"    context: 200000\" instead of a third level.","If the value is genuinely a nested document, move it to a separate file the generator supports — this parser will not carry it."],"exampleFix":"# before\n- provider: anthropic\n  limits:\n    context:\n      tokens: 200000\n\n# after\n- provider: anthropic\n  limits:\n    context_tokens: 200000","handlingStrategy":"validation","validationCode":"function maxTwoLevels(text) {\n  return text.split(\"\\n\").every((line) => !/^ {4}[A-Za-z_][A-Za-z0-9_]*:\\s*$/.test(line.replace(/\\s+$/, \"\")));\n}","typeGuard":null,"tryCatchPattern":"try {\n  parseCatalog(text);\n} catch (err) {\n  if (/nesting deeper than two levels/.test(err.message)) {\n    // flatten the valueless indent-4 key into a combined \"parent_child: value\" pair\n  } else throw err;\n}","preventionTips":["Keep catalog data flat by design — two levels maximum.","Move deeply structured config to a real YAML/JSON file consumed by other tooling."],"tags":["yaml","parser","nesting","code-generation"],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}