{"record":{"id":"4f2c37beed8c90ae","repo":"JuliusBrussee/caveman","slug":"no-json-schemas-found","errorCode":null,"errorMessage":"no JSON schemas found","messagePattern":"no JSON schemas found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/shared/contracts/scripts/validate-schemas.mjs","lineNumber":13,"sourceCode":"import { readdir, readFile } from \"node:fs/promises\";\nimport { fileURLToPath } from \"node:url\";\nimport path from \"node:path\";\nimport Ajv2020 from \"ajv/dist/2020.js\";\n\nconst packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), \"..\");\nconst schemaRoot = path.join(packageRoot, \"schemas\");\nconst files = (await readdir(schemaRoot))\n  .filter((name) => name.endsWith(\".schema.json\"))\n  .sort();\n\nif (files.length === 0) {\n  throw new Error(\"no JSON schemas found\");\n}\n\nconst schemas = [];\nfor (const file of files) {\n  const schema = JSON.parse(await readFile(path.join(schemaRoot, file), \"utf8\"));\n  if (schema.$schema !== \"https://json-schema.org/draft/2020-12/schema\") {\n    throw new Error(`${file}: unsupported or missing $schema`);\n  }\n  if (typeof schema.$id !== \"string\" || schema.$id.length === 0) {\n    throw new Error(`${file}: missing $id`);\n  }\n  schemas.push(schema);\n}\n\nconst ajv = new Ajv2020({ allErrors: true, strict: true });\najv.addSchema(schemas);\nfor (const schema of schemas) {\n  const validate = ajv.getSchema(schema.$id);","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/shared/contracts/scripts/validate-schemas.mjs#L1-L31","documentation":"This schema validation script reads packages/shared/contracts/schemas and expects at least one *.schema.json file. If the directory is empty or the filter matches nothing, it throws 'no JSON schemas found' because validating zero schemas would silently pass. It is a sanity gate on the schema package's contents.","triggerScenarios":"Running scripts/validate-schemas.mjs when packages/shared/contracts/schemas contains no files ending in .schema.json (empty dir, renamed files, wrong extension like .json only, or schemaRoot pointing at the wrong path).","commonSituations":"Schemas renamed from foo.schema.json to foo.json; schemas moved to another directory without updating the script; fresh checkout where schema files were gitignored by an over-broad .gitignore rule.","solutions":["Verify packages/shared/contracts/schemas exists and contains *.schema.json files","Rename schemas to use the .schema.json extension","Fix any .gitignore rule or copy step that excludes schema files from the checkout/package","Check that packageRoot resolution in the script points at the contracts package directory"],"exampleFix":"// before\nschemas/\n  adapter-conformance.json\n// after\nschemas/\n  adapter-conformance.schema.json","handlingStrategy":"validation","validationCode":"import { readdir } from 'node:fs/promises';\nconst files = (await readdir(schemaRoot)).filter(n => n.endsWith('.schema.json'));\nif (files.length === 0) throw new Error(`no schemas at ${schemaRoot}; check checkout and .gitignore`);","typeGuard":null,"tryCatchPattern":"try { await runSchemaValidation(); } catch (e) { if (e.message === 'no JSON schemas found') { console.error(`Schemas missing at ${schemaRoot}`); process.exitCode = 1; } else throw e; }","preventionTips":["Keep the .schema.json extension convention documented in CONTRIBUTING","Check .gitignore for patterns that would exclude schemas/","Verify the schemas directory exists after fresh clone before running validation"],"tags":["filesystem","schemas","validation"],"backgroundTag":"empty-result-set","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}