abhigyanpatwari/GitNexus · error · Error
Spring YAML traversal depth exceeds ${MAX_YAML_TRAVERSAL_DEP
Error message
Spring YAML traversal depth exceeds ${MAX_YAML_TRAVERSAL_DEPTH} What it means
A depth guard inside the Spring YAML config traversal (`consumeYamlTraversalBudget`). The YAML event tree is walked to extract Spring config keys; this throws when the nesting `depth` exceeds `MAX_YAML_TRAVERSAL_DEPTH` (128). It is a hard cap against pathologically deep YAML (including runaway alias/anchor recursion), protecting the ingestion phase from a stack-blowing or time-bombing config file. The parser itself is also invoked with `maxDepth: 128`, so a file this deep is almost always malformed or malicious.
Source
Thrown at gitnexus/src/core/ingestion/pipeline-phases/spring-config.ts:166
readonly kind: 'scalar' | 'sequence' | 'mapping' | 'alias' | null;
readonly result: unknown;
readonly aliasOf: YamlParseEvent | undefined;
readonly children: YamlParseEvent[];
}
interface YamlMappingLocation {
readonly valueEvent: YamlParseEvent;
readonly line: number;
}
interface YamlTraversalState {
remainingNodes: number;
readonly activeObjects: Set<object>;
}
function consumeYamlTraversalBudget(state: YamlTraversalState, depth: number): void {
if (depth > MAX_YAML_TRAVERSAL_DEPTH) {
throw new Error(`Spring YAML traversal depth exceeds ${MAX_YAML_TRAVERSAL_DEPTH}`);
}
state.remainingNodes--;
if (state.remainingNodes < 0) {
throw new Error(`Spring YAML traversal exceeds ${MAX_YAML_TRAVERSAL_NODES} nodes`);
}
}
function isObjectValue(value: unknown): value is object {
return value !== null && typeof value === 'object';
}
// Aliases are resolved to their anchor event by name while the tree is built,
// so following one here is a single pointer hop.
function resolveYamlAliasEvent(event: YamlParseEvent | undefined): YamlParseEvent | undefined {
return event?.aliasOf ?? event;
}
function yamlMappingPairs(event: YamlParseEvent): Array<{View on GitHub (pinned to d540b00184)
Solutions
- Inspect the reported Spring YAML file and flatten its structure to under 128 levels of nesting.
- Remove or fix recursive/self-referential YAML anchors that inflate nesting depth.
- If the file is not a real Spring config, move it out of the scanned config directory or add a `.gitnexusignore` rule for it.
Defensive patterns
Strategy: try-catch
Try / catch
try {
await extractSpringConfig(repoPath);
} catch (err) {
if (/Spring YAML traversal depth exceeds/.test(err.message)) {
// One config file is pathologically deep — log and continue indexing the rest,
// or surface to the operator to flatten the file.
logger.warn(`Skipping deeply-nested Spring config: ${err.message}`);
return;
}
throw err;
} Prevention
- Lint Spring YAML files for excessive nesting in CI.
- Avoid recursive YAML anchors in config consumed by GitNexus.
- Keep machine-generated YAML flattened where possible.
When it happens
Trigger: The Spring config extractor encounters a `.yml`/`.yaml` file whose nesting depth exceeds 128 levels during `consumeYamlTraversalBudget`. Typically caused by recursive YAML anchors, machine-generated deeply-nested config, or a file misidentified as a Spring config that is actually data.
Common situations: A generated Spring config from a templating tool that emits deeply nested maps; a YAML file with self-referential anchors producing deep alias chains; a data file (not config) that landed in a `resources/` dir and was picked up by the Spring config heuristic.
Related errors
- Spring YAML traversal exceeds ${MAX_YAML_TRAVERSAL_NODES} no
- Invalid YAML: expected an object
- version is required in group.yaml
- Unsupported group.yaml version: ${raw.version}. Expected 1.
- name is required in group.yaml
AI-assisted analysis of abhigyanpatwari/GitNexus@d540b00184 (2026-08-12).
Data as JSON: /api/errors/cecc3fe50bbc2b8a.
Report an issue: GitHub.