{"record":{"id":"bdde8876aa8488bf","repo":"1Panel-dev/1Panel","slug":"unexpected-token-s-s-on-line-d-column-d","errorCode":null,"errorMessage":"unexpected token %s (%s) on line %d, column %d","messagePattern":"unexpected token (.+?) \\((.+?)\\) on line (.+?), column (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/utils/nginx/parser/parser.go","lineNumber":182,"sourceCode":"\t\tblock, err := p.parseBlock(false)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tblock.Comment = inLineComment\n\t\td.Block = block\n\n\t\tif strings.HasSuffix(d.Name, \"_by_lua_block\") {\n\t\t\treturn p.blockWrappers[\"_by_lua_block\"](d)\n\t\t}\n\n\t\tif bw, ok := p.blockWrappers[d.Name]; ok {\n\t\t\treturn bw(d)\n\t\t}\n\t\treturn d, nil\n\t}\n\n\tpanic(fmt.Errorf(\"unexpected token %s (%s) on line %d, column %d\", p.currentToken.Type.String(), p.currentToken.Literal, p.currentToken.Line, p.currentToken.Column))\n}\n\nfunc (p *Parser) wrapLocation(directive *components.Directive) *components.Location {\n\treturn components.NewLocation(directive)\n}\n\nfunc (p *Parser) wrapServer(directive *components.Directive) *components.Server {\n\ts, _ := components.NewServer(directive)\n\treturn s\n}\n\nfunc (p *Parser) wrapUpstream(directive *components.Directive) *components.Upstream {\n\ts, _ := components.NewUpstream(directive)\n\treturn s\n}\n\nfunc (p *Parser) wrapHttp(directive *components.Directive) *components.Http {\n\th, _ := components.NewHttp(directive)","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/1Panel-dev/1Panel/blob/5ac7c808815b0691009cd390414f03471312262f/agent/utils/nginx/parser/parser.go#L164-L200","documentation":"Generic parser panic: a token appears where no production accepts it — the token's type/literal and its line/column are included. Typically an unexpected '}' (or ';' in a bad spot, or a stray keyword) after a directive that parseDirective cannot extend.","triggerScenarios":"agent/utils/nginx/parser.Parser.parse encounters a token that is neither a block opener nor a valid continuation — e.g. an extra '}' closing a server{} twice, or a directive missing its ';' terminator so the next keyword is mis-read.","commonSituations":"Merging config snippets that each brought their own '}'; deleting a ';' during edits; includes with unbalanced braces; WAF rule files edited by hand.","solutions":["Go to the exact line:column in the message and fix the token there (remove stray '}' or add the missing ';')","Use nginx -t on the file to cross-check brace/semicolon balance","Revert to the last known-good config version from 1Panel history and reapply edits in smaller steps"],"exampleFix":"# before (missing ';' then stray '}')\nserver_name a.com\n}\n}\n# after\nserver_name a.com;\n}","handlingStrategy":"validation","validationCode":"nginx -t -c /opt/1panel/apps/openresty/openresty/conf/nginx.conf  # catches the syntax issue before the agent parser panics","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always nginx -t after editing; the panic message's line:column mirrors what nginx -t reports","Apply config edits incrementally and keep 1Panel config history enabled for instant revert"],"tags":["nginx","parser","go","panic","syntax"],"backgroundTag":null,"analyzedSha":"5ac7c808815b0691009cd390414f03471312262f","analyzedAt":"2026-08-15T14:02:06.953Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}