1Panel-dev/1Panel · error
unexpected token %s (%s) on line %d, column %d
Error message
unexpected token %s (%s) on line %d, column %d
What it means
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.
Source
Thrown at agent/utils/nginx/parser/parser.go:182
block, err := p.parseBlock(false)
if err != nil {
return nil, err
}
block.Comment = inLineComment
d.Block = block
if strings.HasSuffix(d.Name, "_by_lua_block") {
return p.blockWrappers["_by_lua_block"](d)
}
if bw, ok := p.blockWrappers[d.Name]; ok {
return bw(d)
}
return d, nil
}
panic(fmt.Errorf("unexpected token %s (%s) on line %d, column %d", p.currentToken.Type.String(), p.currentToken.Literal, p.currentToken.Line, p.currentToken.Column))
}
func (p *Parser) wrapLocation(directive *components.Directive) *components.Location {
return components.NewLocation(directive)
}
func (p *Parser) wrapServer(directive *components.Directive) *components.Server {
s, _ := components.NewServer(directive)
return s
}
func (p *Parser) wrapUpstream(directive *components.Directive) *components.Upstream {
s, _ := components.NewUpstream(directive)
return s
}
func (p *Parser) wrapHttp(directive *components.Directive) *components.Http {
h, _ := components.NewHttp(directive)View on GitHub (pinned to 5ac7c80881)
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
Example fix
# before (missing ';' then stray '}') server_name a.com } } # after server_name a.com; }
Defensive patterns
Strategy: validation
Validate before calling
nginx -t -c /opt/1panel/apps/openresty/openresty/conf/nginx.conf # catches the syntax issue before the agent parser panics
Prevention
- 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
When it happens
Trigger: 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.
Common situations: Merging config snippets that each brought their own '}'; deleting a ';' during edits; includes with unbalanced braces; WAF rule files edited by hand.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- no enough parameter for location
- unexpected end of file while scanning a string, maybe an unc
- unexpected end of file while scanning a string, maybe an unc
- Fatal error config file: %s \n
- init db dir failed, err: %v
AI-assisted analysis of 1Panel-dev/1Panel@5ac7c80881 (2026-08-15).
Data as JSON: /api/errors/bdde8876aa8488bf.
Report an issue: GitHub.