@smithy/eventstream-codec Error: "Reported message length does not match received message length" when decoding converseStream API response in node
#6682
Unanswered
stephmilovic
asked this question in
Q&A
Replies: 1 comment
-
|
Running into same issue, did you figure it out? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Description:
I'm working with LangChain + Bedrock and trying to switch from the Invoke APIs to the Converse APIs. I am hitting the Bedrock APIs directly with axios and handing the result back to LangChain's
NodeHttpHandlerandBedrockRuntimeClientto handle the results.The issue I'm having is in is a different spot in my app where I need to decode the raw stream from the API in order to get the usage object. When using the
InvokeWithResponseStreamAPI, I'm able to use the@smithy/eventstream-codecto decode the final response chunk to get the usage object. However, with theConverseStreamAPI an issue occurs intermittently, with some chunks decoding successfully and others failing with the error:The same decoding logic works reliably with the
InvokeWithResponseStreamAPI, so the issue appears specific toConverseStream. I suspect there may be special encoding applied toConverseStream, but I could not find documentation about how to handle or decode these streams properly.Environment:
v20.15.13.1.9anthropic.claude-3-5-sonnet-20240620-v1:0Steps to Reproduce:
converseStreamAPI in AWS Bedrock to receive a streaming response.Observed Behavior:
Successful Decoding:
Failed Decoding:
Troubleshooting Steps Taken:
Uint8Arrayto ensure message continuity.TextDecoderto verify structure. Can see in the failed decoded chunks, the usage object exists but I cannot parse it out of these strings which appear to be a mix of binary data and JSON-like structures.invokeStream, suggesting the issue is specific toconverseStream.Questions:
converseStreamAPI that differs frominvokeStream?converseStreamAPI response using@smithy/eventstream-codec?converseStreamAPI?Request:
Please provide guidance on decoding the
converseStreamAPI response or clarify if there are specific differences in encoding for this API. Let me know if additional logs, raw data, or debugging information is needed.Beta Was this translation helpful? Give feedback.
All reactions