{"record":{"id":"0134f21dfb81c0a0","repo":"KeygraphHQ/shannon","slug":"failed-to-load-configuration-schema-errmsg","errorCode":null,"errorMessage":"Failed to load configuration schema: ${errMsg}","messagePattern":"Failed to load configuration schema: (.+?)","errorType":"validation","errorClass":"PentestError","httpStatus":null,"severity":"critical","filePath":"apps/worker/src/config-parser.ts","lineNumber":39,"sourceCode":"\n// Handle ESM/CJS interop for ajv-formats using require\nconst require = createRequire(import.meta.url);\nconst addFormats: FormatsPlugin = require('ajv-formats');\n\nconst ajv = new Ajv({ allErrors: true, verbose: true });\naddFormats(ajv);\n\nlet configSchema: object;\nlet validateSchema: ValidateFunction;\n\ntry {\n  const schemaPath = new URL('../configs/config-schema.json', import.meta.url);\n  const schemaContent = await fs.readFile(schemaPath, 'utf8');\n  configSchema = JSON.parse(schemaContent) as object;\n  validateSchema = ajv.compile(configSchema);\n} catch (error) {\n  const errMsg = error instanceof Error ? error.message : String(error);\n  throw new PentestError(`Failed to load configuration schema: ${errMsg}`, 'config', false, {\n    schemaPath: '../configs/config-schema.json',\n    originalError: errMsg,\n  });\n}\n\nconst DANGEROUS_PATTERNS: RegExp[] = [\n  /\\.\\.\\//, // Path traversal\n  /[<>]/, // HTML/XML injection\n  /javascript:/i, // JavaScript URLs\n  /data:/i, // Data URLs\n  /file:/i, // File URLs\n];\n\n/**\n * Format a single AJV error into a human-readable message.\n * Translates AJV error keywords into plain English descriptions.\n */\nfunction formatAjvError(error: ErrorObject): string {","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/KeygraphHQ/shannon/blob/1ae0a142f8525410a688f0309fd003cc5b1d92de/apps/worker/src/config-parser.ts#L21-L57","documentation":"Module-load-time failure while reading or compiling the JSON Schema (config-schema.json) that backs all config validation. This is a packaging/fixture fault, not a user-config problem: the schema file is missing, unreadable, or is invalid JSON / an invalid JSON Schema that ajv.compile rejects. Because it runs at import time, it crashes the worker before any scan starts.","triggerScenarios":"apps/worker/configs/config-schema.json is absent, truncated, or contains invalid JSON; ajv.compile throws on a malformed schema; the file is unreadable due to permissions. Triggered the moment config-parser.ts is imported.","commonSituations":"A broken build that did not copy configs/ into dist; hand-editing the schema to invalid JSON; a pnpm install that left the configs dir empty; a corrupt checkout.","solutions":["Verify the schema file exists and parses: `node -e \"JSON.parse(require('fs').readFileSync('apps/worker/configs/config-schema.json','utf8'))\"`.","Rebuild the worker package (`pnpm run build`) so configs/ is restored.","Re-run `pnpm install` if the configs directory is missing or the checkout is incomplete.","Check file permissions on apps/worker/configs/config-schema.json."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import { readFileSync } from 'node:fs';\ntry {\n  JSON.parse(readFileSync('apps/worker/configs/config-schema.json', 'utf8'));\n} catch (error) {\n  console.error('config-schema.json is missing or invalid JSON:', (error as Error).message);\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":"// The throw happens at module load; guard with a dynamic import in a harness.\ntry {\n  await import('./config-parser.js');\n} catch (error) {\n  if (error instanceof Error && error.message.startsWith('Failed to load configuration schema')) {\n    console.error('Schema fixture missing/corrupt. Rebuild the worker package.');\n    process.exit(1);\n  }\n  throw error;\n}","preventionTips":["Never hand-edit config-schema.json without re-running `pnpm run build`.","Treat a missing/corrupt configs/ dir as a build break — restore from git before importing."],"tags":["config","schema","build","ajv","startup"],"backgroundTag":null,"analyzedSha":"1ae0a142f8525410a688f0309fd003cc5b1d92de","analyzedAt":"2026-08-12T17:40:03.583Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}