{"record":{"id":"4d2dd073551bb59f","repo":"grpc-ecosystem/grpc-gateway","slug":"invalid-segment-in-variable-q-w","errorCode":null,"errorMessage":"invalid segment in variable %q: %w","messagePattern":"invalid segment in variable %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/httprule/parse.go","lineNumber":195,"sourceCode":"\t}\n\treturn literal(lit), nil\n}\n\nfunc (p *parser) variable() (segment, error) {\n\tif _, err := p.accept(\"{\"); err != nil {\n\t\treturn nil, err\n\t}\n\n\tpath, err := p.fieldPath()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar segs []segment\n\tif _, err := p.accept(\"=\"); err == nil {\n\t\tsegs, err = p.segments()\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"invalid segment in variable %q: %w\", path, err)\n\t\t}\n\t} else {\n\t\tsegs = []segment{wildcard{}}\n\t}\n\n\tif _, err := p.accept(\"}\"); err != nil {\n\t\treturn nil, fmt.Errorf(\"unterminated variable segment: %s\", path)\n\t}\n\treturn variable{\n\t\tpath:     path,\n\t\tsegments: segs,\n\t}, nil\n}\n\nfunc (p *parser) fieldPath() (string, error) {\n\tc, err := p.accept(typeIdent)\n\tif err != nil {\n\t\treturn \"\", err","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/grpc-ecosystem/grpc-gateway/blob/a58a4436a376a4bcc7d8f10c4d4f919a8438bba9/internal/httprule/parse.go#L177-L213","documentation":"Parser error from parser.variable: after '{name=' the custom segments inside the variable failed to parse (p.segments errored). The error wraps the underlying segments() failure and names the variable's field path, so a template like '{id=bad~seg}' is rejected.","triggerScenarios":"Thrown at internal/httprule/parse.go:195 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the pattern after '=' inside the braces to use only valid literals and wildcards.","Use a plain '{name}' variable (default wildcard) if a custom pattern is unnecessary."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a58a4436a376a4bcc7d8f10c4d4f919a8438bba9","analyzedAt":"2026-09-02T10:28:31.537Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T16:17:10.729Z"}