{"record":{"id":"dfd87e98a926a2e3","repo":"KeygraphHQ/shannon","slug":"config-parse-error","errorCode":"CONFIG_PARSE_ERROR","errorMessage":"YAML parsing failed: ${errMsg}","messagePattern":"YAML parsing failed: (.+?)","errorType":"validation","errorClass":"PentestError","httpStatus":null,"severity":"error","filePath":"apps/worker/src/config-parser.ts","lineNumber":227,"sourceCode":"        'Configuration file is empty',\n        'config',\n        false,\n        { configPath },\n        ErrorCode.CONFIG_VALIDATION_FAILED,\n      );\n    }\n\n    // 4. Parse YAML with safe schema\n    let config: unknown;\n    try {\n      config = yaml.load(configContent, {\n        schema: yaml.FAILSAFE_SCHEMA, // Only basic YAML types, no JS evaluation\n        json: false, // Don't allow JSON-specific syntax\n        filename: configPath,\n      });\n    } catch (yamlError) {\n      const errMsg = yamlError instanceof Error ? yamlError.message : String(yamlError);\n      throw new PentestError(\n        `YAML parsing failed: ${errMsg}`,\n        'config',\n        false,\n        { configPath, originalError: errMsg },\n        ErrorCode.CONFIG_PARSE_ERROR,\n      );\n    }\n\n    // 5. Guard against null/undefined parse result\n    if (config === null || config === undefined) {\n      throw new PentestError(\n        'Configuration file resulted in null/undefined after parsing',\n        'config',\n        false,\n        { configPath },\n        ErrorCode.CONFIG_PARSE_ERROR,\n      );\n    }","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/KeygraphHQ/shannon/blob/1ae0a142f8525410a688f0309fd003cc5b1d92de/apps/worker/src/config-parser.ts#L209-L245","documentation":"parseConfig wraps a js-yaml throw when the config file is syntactically invalid YAML. Parsing uses FAILSAFE_SCHEMA (basic types only, no JS evaluation) and json:false. Classified CONFIG_PARSE_ERROR (non-retryable). The underlying js-yaml message is embedded.","triggerScenarios":"Tabs used for indentation, unclosed quotes or brackets, mixed indentation, or any structural YAML error in the -c file.","commonSituations":"Editor inserting tabs; hand-editing that breaks quoting; merging config fragments with inconsistent indentation.","solutions":["Lint the file with yamllint or a YAML-aware editor.","Fix the specific syntax error named in the embedded js-yaml message.","Re-parse in a REPL: `require('js-yaml').load(require('fs').readFileSync(path,'utf8'))` to iterate quickly."],"exampleFix":"# before (tab indentation -> YAML error)\nrules:\n\tavoid:\n\t  - type: url_path\n\n# after (spaces)\nrules:\n  avoid:\n    - type: url_path","handlingStrategy":"try-catch","validationCode":"import yaml from 'js-yaml';\nimport { readFile } from 'zx/fs';\ntry {\n  yaml.load(await readFile(configPath, 'utf8'), { schema: yaml.FAILSAFE_SCHEMA });\n} catch (error) {\n  console.error('YAML syntax error:', (error as Error).message);\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await parseConfig(configPath);\n} catch (error) {\n  if (error instanceof PentestError && error.code === ErrorCode.CONFIG_PARSE_ERROR && error.message.startsWith('YAML parsing failed')) {\n    // fix the named syntax error in the file, then re-run\n    console.error(error.context.originalError);\n    process.exit(1);\n  }\n  throw error;\n}","preventionTips":["Configure your editor to use spaces, never tabs, for YAML.","Run yamllint on config files in CI before invoking the CLI."],"tags":["config","yaml","parse"],"backgroundTag":null,"analyzedSha":"1ae0a142f8525410a688f0309fd003cc5b1d92de","analyzedAt":"2026-08-12T17:40:03.583Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}