{"record":{"id":"f5549a9359a9cdbe","repo":"continuedev/continue","slug":"invalid-agent-file-frontmatter-errordetails","errorCode":null,"errorMessage":"Invalid agent file frontmatter: ${errorDetails}","messagePattern":"Invalid agent file frontmatter: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/config-yaml/src/markdown/agentFiles.ts","lineNumber":63,"sourceCode":" * Parses and validates an agent file from markdown content\n * Agent files must have frontmatter with at least a name\n */\nexport function parseAgentFile(content: string): AgentFile {\n  const { frontmatter, markdown } = parseMarkdownRule(content);\n\n  if (!frontmatter.name) {\n    throw new Error(\n      \"Agent file must contain YAML frontmatter with a 'name' field\",\n    );\n  }\n\n  const validationResult = agentFileFrontmatterSchema.safeParse(frontmatter);\n\n  if (!validationResult.success) {\n    const errorDetails = validationResult.error.issues\n      .map((issue) => `${issue.path.join(\".\")}: ${issue.message}`)\n      .join(\", \");\n    throw new Error(`Invalid agent file frontmatter: ${errorDetails}`);\n  }\n\n  return {\n    ...validationResult.data,\n    prompt: markdown,\n  };\n}\n\n/**\n * Serializes an Agent file back to markdown with YAML frontmatter\n */\nexport function serializeAgentFile(agentFile: AgentFile): string {\n  const { prompt, ...frontmatter } = agentFile;\n\n  // Filter out undefined values from frontmatter\n  const cleanFrontmatter = Object.fromEntries(\n    Object.entries(frontmatter).filter(([, value]) => value !== undefined),\n  );","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/packages/config-yaml/src/markdown/agentFiles.ts#L45-L81","documentation":"parseAgentFile validates frontmatter with agentFileFrontmatterSchema via safeParse; on failure it joins all issue paths and messages into one descriptive error. 'name' exists but other fields are invalid.","triggerScenarios":"Frontmatter with a 'name' but invalid types/values for other fields — e.g. tools not a list, description not a string, unknown field constraints per the schema.","commonSituations":"Schema evolution adding stricter field validation after an upgrade, hand-edited frontmatter with wrong YAML types (string vs list).","solutions":["Read the message: each 'path: message' pair names the exact bad field","Fix or remove the listed fields","Regenerate frontmatter from a known-valid example for the current version"],"exampleFix":"# before\n---\nname: a\ntools: tool1\n---\n# after\n---\nname: a\ntools:\n  - tool1\n---","handlingStrategy":"validation","validationCode":"import { agentFileFrontmatterSchema } from '...';\nconst fm = parseMarkdownRule(content).frontmatter;\nconst r = agentFileFrontmatterSchema.safeParse(fm);\nif (!r.success) console.log(r.error.issues);","typeGuard":null,"tryCatchPattern":"try { parseAgentFile(content); } catch (e) { if (e.message.startsWith('Invalid agent file frontmatter')) { /* show field list */ } }","preventionTips":["Use correct YAML types (lists as lists)","Validate agent files in CI"],"tags":["agent-file","zod","frontmatter","validation"],"backgroundTag":"schema-validation-failed","analyzedSha":"5522c6f44ca0ac3528b37244818fbfa39b5af470","analyzedAt":"2026-08-27T11:28:54.683Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}