{"record":{"id":"9f338676466ba0b9","repo":"sigoden/aichat","slug":"unrecognized-message-message-type-message-type","errorCode":null,"errorMessage":"Unrecognized message, message_type: {message_type}, smithy_type: {smithy_type}","messagePattern":"Unrecognized message, message_type: (.+?), smithy_type: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/client/bedrock.rs","lineNumber":294,"sourceCode":"                                })?;\n                                handler.tool_call(ToolCall::new(\n                                    function_name.clone(),\n                                    arguments,\n                                    Some(function_id.clone()),\n                                ))?;\n                            }\n                        }\n                        _ => {}\n                    }\n                }\n                (\"exception\", _) => {\n                    let payload = base64_decode(message.payload())?;\n                    let data = String::from_utf8_lossy(&payload);\n\n                    bail!(\"Invalid response data: {data} (smithy_type: {smithy_type})\")\n                }\n                _ => {\n                    bail!(\"Unrecognized message, message_type: {message_type}, smithy_type: {smithy_type}\",);\n                }\n            }\n        }\n    }\n    Ok(())\n}\n\nasync fn embeddings(builder: RequestBuilder) -> Result<EmbeddingsOutput> {\n    let res = builder.send().await?;\n    let status = res.status();\n    let data: Value = res.json().await?;\n\n    if !status.is_success() {\n        catch_error(&data, status.as_u16())?;\n    }\n\n    let res_body: EmbeddingsResBody =\n        serde_json::from_value(data).context(\"Invalid embeddings data\")?;","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/sigoden/aichat/blob/82976d349ad97ac9aae0655ad631dace5e2a6385/src/client/bedrock.rs#L276-L312","documentation":"The Bedrock EventStream decoder received a message whose (message_type, smithy_type) pair matches none of the known branches (event/exception variants). The library bails with 'Unrecognized message' echoing both identifiers. This guards against new or unknown smithy event shapes being silently dropped.","triggerScenarios":"chat_completions_streaming decodes an event-stream message whose message_type/smithy_type combination falls into the catch-all '_' arm of the match in the streaming loop.","commonSituations":"AWS introduced a new event type not yet handled by this library version, a protocol/SDK version mismatch between reqwest eventsource handling and Bedrock's stream, or corrupted/unexpected framing from a proxy.","solutions":["Log the message_type and smithy_type values reported and compare against Bedrock's EventStream API docs","Update the library (and aws-smithy event-stream handling) to a version that knows the new event type","File/track an issue upstream to add a handler for the reported smithy_type","Bypass intermediaries/proxies that might rewrite the event stream","Pin to a Bedrock API version/model whose stream events are supported"],"exampleFix":"// before\nrig = \"0.x\"  # old client without new event handler\n// after\nrig = \"latest\"  # or patch the match in src/client/bedrock.rs to handle the new smithy_type","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"match client.chat_completions_streaming(req).await {\n    Err(e) if e.to_string().starts_with(\"Unrecognized message\") => {\n        log::warn!(\"unknown bedrock event: {e}; falling back to non-streaming\");\n        client.chat_completions(req).await\n    }\n    r => r,\n}","preventionTips":["Keep the library updated so new smithy event types are handled","Capture message_type/smithy_type from the message and report upstream","Avoid proxies that may alter event-stream framing","Pin supported model/API versions"],"tags":["aws","bedrock","streaming","event-stream","unknown-message"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"82976d349ad97ac9aae0655ad631dace5e2a6385","analyzedAt":"2026-09-09T18:33:06.139Z","contentChangedAt":"2026-09-09T18:33:06.139Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}