{"record":{"id":"7023149317ac0e60","repo":"JuliusBrussee/caveman","slug":"label-lineno-blockkey-mixes-map-and-se","errorCode":null,"errorMessage":"${label}:${lineNo}: \"${blockKey}\" mixes map and sequence entries","messagePattern":"(.+?):(.+?): \"(.+?)\" mixes map and sequence entries","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/generate-agent-catalog.mjs","lineNumber":90,"sourceCode":"      if (dash) throw new Error(`${label}:${lineNo}: unexpected sequence item at row level`);\n      const entry = splitKeyValue(rest, label, lineNo);\n      if (Object.prototype.hasOwnProperty.call(row, entry.key)) {\n        throw new Error(`${label}:${lineNo}: duplicate key \"${entry.key}\"`);\n      }\n      if (entry.value === undefined) {\n        blockKey = entry.key;\n        row[entry.key] = undefined;\n      } else {\n        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;","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/scripts/generate-agent-catalog.mjs#L72-L108","documentation":"Thrown by the catalog parser (dash branch) when a \"- \" item at indent 4 is added to a block key whose value was already established as a map (an object), not a sequence. The parser allows a block key to hold either a list of items or a map of sub-keys, but not both — mixing them would produce an ambiguous structure the generator cannot render.","triggerScenarios":"Under one block key, first writing \"    subkey: value\" (making it a map) and later \"    - item\" (a sequence item), e.g. \"  endpoints:\" containing both \"    - /v1\" and \"    default: /v1\".","commonSituations":"Growing a config block incrementally where an early map entry sets the type and a later edit adds list items (or vice versa); pasting heterogeneous examples into one block.","solutions":["Pick one shape for the block named in the error: all indent-4 \"- item\" lines (sequence) or all indent-4 \"key: value\" lines (map), and rewrite the block accordingly.","If you need both, split into two sibling block keys at indent 2 (e.g. \"endpoints:\" and \"default_endpoint:\")."],"exampleFix":"# before\n- provider: anthropic\n  endpoints:\n    default: /v1/messages\n    - /v1/count_tokens\n\n# after\n- provider: anthropic\n  endpoints:\n    - /v1/messages\n    - /v1/count_tokens\n  default_endpoint: /v1/messages","handlingStrategy":"validation","validationCode":"function blockNotMixed(text) {\n  const blocks = new Map();\n  let current = null;\n  for (const line of text.split(\"\\n\")) {\n    const m = /^ {2}([A-Za-z_][A-Za-z0-9_]*):\\s*$/.exec(line.replace(/\\s+$/, \"\"));\n    if (m) { current = m[1]; blocks.set(current, new Set()); continue; }\n    if (/^ {4}- /.test(line) && current) blocks.get(current).add(\"seq\");\n    else if (/^ {4}[A-Za-z_]/.test(line) && current) blocks.get(current).add(\"map\");\n  }\n  return [...blocks.values()].every((s) => s.size <= 1);\n}","typeGuard":null,"tryCatchPattern":"try {\n  parseCatalog(text);\n} catch (err) {\n  if (/mixes map and sequence entries/.test(err.message)) {\n    // split the named blockKey into one sequence block and one map block\n  } else throw err;\n}","preventionTips":["Decide each block's shape (list or map) before writing it and stick to it.","Put metadata like \"default\" in a sibling indent-2 key, never inside a list block."],"tags":["yaml","parser","type-conflict","code-generation"],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}