{"record":{"id":"8cd0e9d5816f179f","repo":"nats-io/nats-server","slug":"parse-error-on-line-d-s","errorCode":null,"errorMessage":"Parse error on line %d: '%s'","messagePattern":"Parse error on line (.+?): '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"conf/parse.go","lineNumber":283,"sourceCode":"\t}\n\tli := len(p.ikeys) - 1\n\tlast := p.ikeys[li]\n\tp.ikeys = p.ikeys[0:li]\n\treturn last\n}\n\nfunc (p *parser) processItem(it item, fp string) error {\n\tsetValue := func(it item, v any) {\n\t\tif p.pedantic {\n\t\t\tp.setValue(&token{it, v, false, fp})\n\t\t} else {\n\t\t\tp.setValue(v)\n\t\t}\n\t}\n\n\tswitch it.typ {\n\tcase itemError:\n\t\treturn fmt.Errorf(\"Parse error on line %d: '%s'\", it.line, it.val)\n\tcase itemKey:\n\t\t// Keep track of the keys as items and strings,\n\t\t// we do this in order to be able to still support\n\t\t// includes without many breaking changes.\n\t\tp.pushKey(it.val)\n\n\t\tif p.pedantic {\n\t\t\tp.pushItemKey(it)\n\t\t}\n\tcase itemMapStart:\n\t\tnewCtx := make(map[string]any)\n\t\tp.pushContext(newCtx)\n\tcase itemMapEnd:\n\t\tsetValue(it, p.popContext())\n\tcase itemString:\n\t\t// FIXME(dlc) sanitize string?\n\t\tsetValue(it, it.val)\n\tcase itemInteger:","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/conf/parse.go#L265-L301","documentation":"processItem receives items from the lexer and, when the item type is itemError (lexical failure), converts it into \"Parse error on line %d: '%s'\". The library surfaces lexer-level problems — unterminated strings, illegal characters, bad tokens — at a precise line number.","triggerScenarios":"A config file contains a token the lexer cannot handle, e.g. an unterminated quoted string, an invalid escape, or an unexpected character; processItem is invoked from parse for every token.","commonSituations":"Secrets pasted with a trailing unclosed quote; special characters (backticks, unescaped quotes) in passwords; variables expanded with characters the lexer rejects; Windows line-ending or encoding oddities.","solutions":["Go to the reported line and fix the quoted token — close the quote or escape inner quotes","Wrap problematic values (passwords, URLs with special chars) in single or double quotes properly","Replace illegal characters or remove BOM/encoding artifacts","Validate with `nats-server -t -c file.conf` after editing"],"exampleFix":"// before\nauthorization {\n  password: \"p@ss'word\n}\n// after\nauthorization {\n  password: \"p@ss'word\"\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"cfg, err := conf.ParseFile(fp)\nif err != nil {\n    var line int\n    if n, _ := fmt.Sscanf(err.Error(), \"Parse error on line %d\", &line); n == 1 {\n        log.Fatalf(\"lexer failure in %s at line %d: inspect quotes/characters there\", fp, line)\n    }\n    return err\n}","preventionTips":["Quote all values containing special characters or spaces","Never paste secrets with unbalanced quotes into configs","Use nats-server -t as a pre-deploy syntax gate","Normalize file encoding (UTF-8, no BOM) before parsing"],"tags":["config","syntax","lexer","nats-server"],"backgroundTag":"config-syntax-error","analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}