{"record":{"id":"2f4bfeaf32790dc4","repo":"Fission-AI/OpenSpec","slug":"invalid-schema-errors","errorCode":null,"errorMessage":"Invalid schema: ${errors}","messagePattern":"Invalid schema: (.+?)","errorType":"exception","errorClass":"SchemaValidationError","httpStatus":null,"severity":"error","filePath":"src/core/artifact-graph/schema.ts","lineNumber":30,"sourceCode":"/**\n * Loads and validates an artifact schema from a YAML file.\n */\nexport function loadSchema(filePath: string): SchemaYaml {\n  const content = fs.readFileSync(filePath, 'utf-8');\n  return parseSchema(content);\n}\n\n/**\n * Parses and validates an artifact schema from YAML content.\n */\nexport function parseSchema(yamlContent: string): SchemaYaml {\n  const parsed = parseYaml(yamlContent);\n\n  // Validate with Zod\n  const result = SchemaYamlSchema.safeParse(parsed);\n  if (!result.success) {\n    const errors = result.error.issues.map(e => `${e.path.join('.')}: ${e.message}`).join(', ');\n    throw new SchemaValidationError(`Invalid schema: ${errors}`);\n  }\n\n  const schema = result.data;\n\n  // Check for duplicate artifact IDs\n  validateNoDuplicateIds(schema.artifacts);\n\n  // Check that all requires references are valid\n  validateRequiresReferences(schema.artifacts);\n\n  // Check for cycles\n  validateNoCycles(schema.artifacts);\n\n  return schema;\n}\n\n/**\n * Validates that there are no duplicate artifact IDs.","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/Fission-AI/OpenSpec/blob/6926ccb18afa4ff621112813e9968334576ee11a/src/core/artifact-graph/schema.ts#L12-L48","documentation":"Generic guard in parseSchema: after YAML parsing, the document failed Zod validation against SchemaYamlSchema. The message lists each issue as a path plus message, identifying exactly which field of the parsed YAML document is malformed.","triggerScenarios":"Thrown at src/core/artifact-graph/schema.ts:30 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix each 'path: message' pair listed in the error at the corresponding location in the YAML","Ensure required top-level fields (e.g. artifacts array) are present and correctly typed","Re-run validation until no Zod issues remain"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6926ccb18afa4ff621112813e9968334576ee11a","analyzedAt":"2026-08-25T12:29:45.729Z","contentChangedAt":"2026-08-25T12:29:45.729Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}