{"record":{"id":"52598ef24aa3d6f7","repo":"nats-io/nats-server","slug":"error-parsing-include-file-s-v","errorCode":null,"errorMessage":"error parsing include file '%s', %v","messagePattern":"error parsing include file '(.+?)', (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"conf/parse.go","lineNumber":419,"sourceCode":"\t\t\tdefault:\n\t\t\t\t// Special case to add position context to bcrypt references.\n\t\t\t\tp.setValue(&token{it, value, false, fp})\n\t\t\t}\n\t\t} else {\n\t\t\tp.setValue(value)\n\t\t}\n\tcase itemInclude:\n\t\tvar (\n\t\t\tm   map[string]any\n\t\t\terr error\n\t\t)\n\t\tif p.pedantic {\n\t\t\tm, err = ParseFileWithChecks(filepath.Join(p.fp, it.val))\n\t\t} else {\n\t\t\tm, err = ParseFile(filepath.Join(p.fp, it.val))\n\t\t}\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error parsing include file '%s', %v\", it.val, err)\n\t\t}\n\t\tfor k, v := range m {\n\t\t\tp.pushKey(k)\n\n\t\t\tif p.pedantic {\n\t\t\t\tswitch tk := v.(type) {\n\t\t\t\tcase *token:\n\t\t\t\t\tp.pushItemKey(tk.item)\n\t\t\t\t}\n\t\t\t}\n\t\t\tp.setValue(v)\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// Used to map an environment value into a temporary map to pass to secondary Parse call.","sourceCodeStart":401,"sourceCodeEnd":437,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/conf/parse.go#L401-L437","documentation":"An include item caused the parser to recursively parse the referenced file (ParseFile, or ParseFileWithChecks in pedantic mode) at filepath.Join(p.fp, it.val); that inner parse returned an error, which is wrapped and re-reported with the include file's name.","triggerScenarios":"processItem (from parse) hits the include case and the included file has any parse error — bad syntax, out-of-range floats, unknown variable references, wrong types — or the path resolves to an unreadable/invalid file.","commonSituations":"Included config was edited and broke, include path typo resolving to the wrong file, relative path assumptions differing from p.fp, or recursive includes producing failures.","solutions":["Parse the included file standalone (the %v suffix holds the root cause) and fix the inner error first.","Verify the include path resolves correctly relative to the parent config's directory (p.fp).","Ensure the file exists and is readable with the expected format.","Check for circular includes or accidentally including a non-config file."],"exampleFix":"// before (parent.conf)\ninclude = common/confg.conf   # typo\n// after\ninclude = common/conf.conf","handlingStrategy":"try-catch","validationCode":"if _, err := os.Stat(includePath); err != nil {\n\treturn fmt.Errorf(\"include %q unreadable: %w\", includePath, err)\n}\nif err := conf.ParseFile(includePath); err != nil {\n\treturn fmt.Errorf(\"include %q invalid: %w\", includePath, err)\n}","typeGuard":null,"tryCatchPattern":"if err := parseConfig(); err != nil {\n\tvar ierr error\n\tif _, gerr := fmt.Sscanf(err.Error(), \"error parsing include file %q, %v\", new(string), &ierr); gerr == nil && ierr != nil {\n\t\treturn fmt.Errorf(\"bad include: %w\", ierr)\n\t}\n\treturn err\n}","preventionTips":["Validate each include file in CI independently.","Use paths relative to the parent config's directory and test them.","Avoid circular includes; keep an include dependency graph.","After editing an included file, re-run the full config parse before deploy."],"tags":["config","include","parsing","file-io"],"backgroundTag":"config-include-failed","analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}