{"record":{"id":"eb6327c97a6ea6e1","repo":"grpc-ecosystem/grpc-gateway","slug":"expected-eof-but-got-q","errorCode":null,"errorMessage":"expected EOF but got %q","messagePattern":"expected EOF but got %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/httprule/parse.go","lineNumber":256,"sourceCode":"\ttypeEOF     = termType(\"$\")\n)\n\n// eof is the terminal symbol which always appears at the end of token sequence.\nconst eof = \"\\u0000\"\n\n// accept tries to accept a token in \"p\".\n// This function consumes a token and returns it if it matches to the specified \"term\".\n// If it doesn't match, the function does not consume any tokens and return an error.\nfunc (p *parser) accept(term termType) (string, error) {\n\tt := p.tokens[0]\n\tswitch term {\n\tcase \"/\", \"*\", \"**\", \".\", \"=\", \"{\", \"}\":\n\t\tif t != string(term) && t != \"/\" {\n\t\t\treturn \"\", fmt.Errorf(\"expected %q but got %q\", term, t)\n\t\t}\n\tcase typeEOF:\n\t\tif t != eof {\n\t\t\treturn \"\", fmt.Errorf(\"expected EOF but got %q\", t)\n\t\t}\n\tcase typeIdent:\n\t\tif err := expectIdent(t); err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\tcase typeLiteral:\n\t\tif err := expectPChars(t); err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"unknown termType %q\", term)\n\t}\n\tp.tokens = p.tokens[1:]\n\tp.accepted = append(p.accepted, t)\n\treturn t, nil\n}\n\n// expectPChars determines if \"t\" consists of only pchars defined in RFC3986.","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/grpc-ecosystem/grpc-gateway/blob/a58a4436a376a4bcc7d8f10c4d4f919a8438bba9/internal/httprule/parse.go#L238-L274","documentation":"Token-mismatch error from parser.accept when the parser required end-of-input but tokens remain (or the token stream is malformed). It fires from topLevelSegments' final accept(typeEOF) check; the message shows the unexpected token still pending.","triggerScenarios":"Thrown at internal/httprule/parse.go:256 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove trailing garbage after the path template in the HttpRule pattern.","Ensure braces/wildcards are balanced so the template ends cleanly."],"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"}