{"record":{"id":"c5ef506ad35d08bb","repo":"JuliusBrussee/caveman","slug":"label-lineno-indented-line-before-any-row","errorCode":null,"errorMessage":"${label}:${lineNo}: indented line before any row","messagePattern":"(.+?):(.+?): indented line before any row","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/generate-agent-catalog.mjs","lineNumber":70,"sourceCode":"  for (let index = 0; index < lines.length; index++) {\n    const line = lines[index].replace(/\\s+$/, \"\");\n    const lineNo = index + 1;\n    if (line === \"\" || /^ *#/.test(line)) continue;\n    const shape = /^( *)(- )?(.*)$/.exec(line);\n    const indent = shape[1].length;\n    const dash = shape[2] !== undefined;\n    const rest = shape[3];\n    if (indent === 0) {\n      if (!dash) throw new Error(`${label}:${lineNo}: expected a top-level \"- provider: ...\" row`);\n      row = {};\n      rows.push(row);\n      blockKey = null;\n      const entry = splitKeyValue(rest, label, lineNo);\n      if (entry.value === undefined) throw new Error(`${label}:${lineNo}: row must start with an inline \"provider\" value`);\n      row[entry.key] = entry.value;\n      continue;\n    }\n    if (row === null) throw new Error(`${label}:${lineNo}: indented line before any row`);\n    if (indent === 2) {\n      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) {","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/scripts/generate-agent-catalog.mjs#L52-L88","documentation":"Thrown by the catalog parser when an indented line appears before any top-level \"- provider: ...\" row has been opened. Indented content can only belong to a row; with row still null there is nothing to attach it to, which almost always means the file's first row is malformed or missing its dash.","triggerScenarios":"The file starts with indented keys (e.g. the \"- provider:\" line was deleted or commented out, or the whole file was re-indented by an editor), or a comment marker was removed leaving orphaned child lines at the top.","commonSituations":"Accidentally deleting the first row's dash line while editing; a formatter re-indenting the file; resolving a merge conflict by keeping only the indented half.","solutions":["Go to the line named by label:lineNo and add the missing top-level \"- provider: <value>\" row above it.","If the orphaned lines belong to a row that was deleted, remove them too or restore the row.","Run the generator again to confirm no further structure errors follow."],"exampleFix":"# before\n  model: claude-4\n  api: messages\n\n# after\n- provider: anthropic\n  model: claude-4\n  api: messages","handlingStrategy":"validation","validationCode":"function firstContentLineIsRow(text) {\n  const first = text.split(\"\\n\").find((l) => l.trim() !== \"\" && !/^ *#/.test(l));\n  return first !== undefined && /^- provider: /.test(first.trimEnd());\n}","typeGuard":null,"tryCatchPattern":"try {\n  parseCatalog(text);\n} catch (err) {\n  if (/indented line before any row/.test(err.message)) {\n    // restore the \"- provider: ...\" header above the line named in the error\n  } else throw err;\n}","preventionTips":["Run the generator immediately after structural edits to catch orphaned lines.","Avoid editors that auto-reindent the whole file on save."],"tags":["yaml","parser","code-generation","catalog"],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}