Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error handling code for Bedrock doesn't work for exception message types #71

Open
preston-m-price opened this issue Dec 13, 2024 · 1 comment

Comments

@preston-m-price
Copy link

There is an error in the SDK here:

case eventstreamapi.ExceptionMessageType:
case eventstreamapi.ErrorMessageType:

In Go, case statements don't fall through. So what we have here is a noop handler for the ExceptionMessageType case.

I learned this while trying to debug an empty response stream for a payload like:

"messages": [
  {
    "role": "user",
    "content": "Tell me a good joke please."
  },
  {
    "role": "assistant",
    "content": "Sure, "
  }]
}

It turns out the Bedrock API is telling the client there is an exception because the last assistant message cannot have trailing whitespace, but the exception returned by Bedrock is eaten by the noop for the ExceptionMessageType case.

This is a one-liner fix. Either update the code to:

case eventstreamapi.ExceptionMessageType:
  fallthrough // <--------- add this
case eventstreamapi.ErrorMessageType:

or

case eventstreamapi.ExceptionMessageType, case eventstreamapi.ErrorMessageType:
@yjp20
Copy link
Contributor

yjp20 commented Dec 19, 2024

Hey! This should now be fixed as of release: 0.2.0-alpha.8, please let us know if you run into any more problems!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants