KeygraphHQ/shannon · error · PentestError

CONFIG_PARSE_ERROR

CONFIG_PARSE_ERROR

Error message

YAML parsing failed: ${errMsg}

What it means

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.

Source

Thrown at apps/worker/src/config-parser.ts:227

        'Configuration file is empty',
        'config',
        false,
        { configPath },
        ErrorCode.CONFIG_VALIDATION_FAILED,
      );
    }

    // 4. Parse YAML with safe schema
    let config: unknown;
    try {
      config = yaml.load(configContent, {
        schema: yaml.FAILSAFE_SCHEMA, // Only basic YAML types, no JS evaluation
        json: false, // Don't allow JSON-specific syntax
        filename: configPath,
      });
    } catch (yamlError) {
      const errMsg = yamlError instanceof Error ? yamlError.message : String(yamlError);
      throw new PentestError(
        `YAML parsing failed: ${errMsg}`,
        'config',
        false,
        { configPath, originalError: errMsg },
        ErrorCode.CONFIG_PARSE_ERROR,
      );
    }

    // 5. Guard against null/undefined parse result
    if (config === null || config === undefined) {
      throw new PentestError(
        'Configuration file resulted in null/undefined after parsing',
        'config',
        false,
        { configPath },
        ErrorCode.CONFIG_PARSE_ERROR,
      );
    }

View on GitHub (pinned to 1ae0a142f8)

Solutions

  1. Lint the file with yamllint or a YAML-aware editor.
  2. Fix the specific syntax error named in the embedded js-yaml message.
  3. Re-parse in a REPL: `require('js-yaml').load(require('fs').readFileSync(path,'utf8'))` to iterate quickly.

Example fix

# before (tab indentation -> YAML error)
rules:
	avoid:
	  - type: url_path

# after (spaces)
rules:
  avoid:
    - type: url_path
Defensive patterns

Strategy: try-catch

Validate before calling

import yaml from 'js-yaml';
import { readFile } from 'zx/fs';
try {
  yaml.load(await readFile(configPath, 'utf8'), { schema: yaml.FAILSAFE_SCHEMA });
} catch (error) {
  console.error('YAML syntax error:', (error as Error).message);
  process.exit(1);
}

Try / catch

try {
  await parseConfig(configPath);
} catch (error) {
  if (error instanceof PentestError && error.code === ErrorCode.CONFIG_PARSE_ERROR && error.message.startsWith('YAML parsing failed')) {
    // fix the named syntax error in the file, then re-run
    console.error(error.context.originalError);
    process.exit(1);
  }
  throw error;
}

Prevention

When it happens

Trigger: Tabs used for indentation, unclosed quotes or brackets, mixed indentation, or any structural YAML error in the -c file.

Common situations: Editor inserting tabs; hand-editing that breaks quoting; merging config fragments with inconsistent indentation.

Related errors


AI-assisted analysis of KeygraphHQ/shannon@1ae0a142f8 (2026-08-12). Data as JSON: /api/errors/dfd87e98a926a2e3. Report an issue: GitHub.