grpc-ecosystem/grpc-gateway · error
segment neither wildcards, literal or variable: %w
Error message
segment neither wildcards, literal or variable: %w
What it means
Fallback error from parser.segment: a path-template segment matched none of '*', '**', literal, or variable (variable() itself failed). The wrapped error describes the underlying cause; the faulting input is the offending segment in the google.api.http path template.
Source
Thrown at internal/httprule/parse.go:168
}
segs = append(segs, s)
}
}
func (p *parser) segment() (segment, error) {
if _, err := p.accept("*"); err == nil {
return wildcard{}, nil
}
if _, err := p.accept("**"); err == nil {
return deepWildcard{}, nil
}
if l, err := p.literal(); err == nil {
return l, nil
}
v, err := p.variable()
if err != nil {
return nil, fmt.Errorf("segment neither wildcards, literal or variable: %w", err)
}
return v, nil
}
func (p *parser) literal() (segment, error) {
lit, err := p.accept(typeLiteral)
if err != nil {
return nil, err
}
return literal(lit), nil
}
func (p *parser) variable() (segment, error) {
if _, err := p.accept("{"); err != nil {
return nil, err
}
path, err := p.fieldPath()View on GitHub (pinned to a58a4436a3)
Solutions
- Rewrite the offending segment as a literal, '*'/'**' wildcard, or '{var}' variable per http.proto syntax.
- Inspect the wrapped cause (e.g. invalid identifier or missing brace) for the exact character problem.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/httprule/parse.go:168 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grpc-ecosystem/grpc-gateway@a58a4436a3 (2026-09-02).
Data as JSON: /api/errors/3f5854a662aabd22.
Report an issue: GitHub.