{"record":{"id":"d16d260733f657ef","repo":"alibaba/open-code-review","slug":"unsupported-protocol-q-supported-protocols-are","errorCode":null,"errorMessage":"unsupported protocol %q; supported protocols are %q, %q, %q, %q","messagePattern":"unsupported protocol %q; supported protocols are %q, %q, %q, %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/llm/protocol.go","lineNumber":70,"sourceCode":"\tcase ProtocolOpenAIChatCompletions:\n\t\treturn ProtocolOpenAIChatCompletions\n\tcase ProtocolOpenAIResponses:\n\t\treturn ProtocolOpenAIResponses\n\tcase ProtocolAnthropicBedrock:\n\t\treturn ProtocolAnthropicBedrock\n\tdefault:\n\t\treturn normalized\n\t}\n}\n\n// ValidateProtocol accepts the four canonical protocol names and rejects\n// everything else.\nfunc ValidateProtocol(p string) error {\n\tswitch p {\n\tcase ProtocolAnthropic, ProtocolOpenAIChatCompletions, ProtocolOpenAIResponses, ProtocolAnthropicBedrock:\n\t\treturn nil\n\tdefault:\n\t\treturn fmt.Errorf(\"unsupported protocol %q; supported protocols are %q, %q, %q, %q\", p, ProtocolAnthropic, ProtocolOpenAIChatCompletions, ProtocolOpenAIResponses, ProtocolAnthropicBedrock)\n\t}\n}\n","sourceCodeStart":52,"sourceCodeEnd":73,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/internal/llm/protocol.go#L52-L73","documentation":"ValidateProtocol accepts only the four canonical protocol names built into open-code-review: \"anthropic\", \"openai\", \"openai-responses\", and \"anthropic-bedrock\". It is the whitelist gate used by config parsing, provider field application, and the LLM client factory. Any other (case-normalized) value fails with this error listing every accepted name.","triggerScenarios":"Setting a protocol value in a provider/custom_providers config section, via applyProviderField, or via OCR_LLM_PROTOCOL that is not one of the four canonical names — e.g. \"OpenAI\" (NormalizeProtocol lowercases, so case is fine, but \"openai-chat\" or \"gpt\" are not), a misspelling like \"anthropic-bedrock \" is trimmed but \"bedrock\" alone is rejected.","commonSituations":"Typing a protocol alias by hand in ~/.opencodereview/config.json; copying a vendor doc name like \"chat-completions\" or \"azure-openai\"; using an old custom value from before \"openai-responses\"/\"anthropic-bedrock\" were introduced.","solutions":["Use one of the exact names: \"anthropic\", \"openai\", \"openai-responses\", or \"anthropic-bedrock\"","Call llm.NormalizeProtocol(raw) first, then ValidateProtocol on the result, to see the canonical form in the error","If you need Bedrock, use \"anthropic-bedrock\" with AWS credentials in the environment rather than a custom protocol string"],"exampleFix":"// before\nprotocol: \"openai-chat\"\n// after\nprotocol: \"openai\"","handlingStrategy":"validation","validationCode":"p := llm.NormalizeProtocol(raw)\nif err := llm.ValidateProtocol(p); err != nil {\n    return fmt.Errorf(\"config protocol %q invalid: %w\", raw, err)\n}","typeGuard":"func isKnownProtocol(p string) bool {\n    switch llm.NormalizeProtocol(p) {\n    case llm.ProtocolAnthropic, llm.ProtocolOpenAIChatCompletions,\n        llm.ProtocolOpenAIResponses, llm.ProtocolAnthropicBedrock:\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Always run NormalizeProtocol before ValidateProtocol so case/whitespace typos are forgiven","Keep protocol strings as the exported llm.Protocol* constants in generated configs","Validate config.json once at startup, not per request"],"tags":["config","validation","llm-protocol"],"backgroundTag":"invalid-enum-value","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}