Add safety check for bedrock ConverseStream responses#3990
Merged
xrmx merged 14 commits intoopen-telemetry:mainfrom Dec 3, 2025
Merged
Add safety check for bedrock ConverseStream responses#3990xrmx merged 14 commits intoopen-telemetry:mainfrom
xrmx merged 14 commits intoopen-telemetry:mainfrom
Conversation
65e10cb to
fde933a
Compare
05bcdf9 to
0861f9f
Compare
xrmx
reviewed
Dec 2, 2025
...trumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/bedrock_utils.py
Show resolved
Hide resolved
…ntelemetry/instrumentation/botocore/extensions/bedrock_utils.py
xrmx
approved these changes
Dec 2, 2025
xrmx
reviewed
Dec 2, 2025
Contributor
|
@liustve Please fix the CI failures and next time please run the tests locally :) |
Contributor
|
@liustve I don't think you pushed a fix for the test: |
Contributor
Author
Apologies, had to fix a few things in my local dev environment, for some reason the tests were using another version of OTel botocore. Also revised the test to better capture the intended behavior. |
xrmx
reviewed
Dec 2, 2025
instrumentation/opentelemetry-instrumentation-botocore/tests/test_botocore_bedrock.py
Show resolved
Hide resolved
…est_botocore_bedrock.py
Contributor
Author
|
@xrmx added another defensive check for |
liustve
added a commit
to aws-observability/aws-otel-python-instrumentation
that referenced
this pull request
Dec 2, 2025
*Description of changes:* Ports the changes from open-telemetry/opentelemetry-python-contrib#3990 Add defensive check for Bedrock responses missing expected structure. When no messageStart event with assistant role is received, the response may lack the standard output.message format, causing the occasional KeyError exceptions. For testing, I was unable to reproduce the exact scenario that would trigger this bug, however, this safety check would fix this issue without affecting normal instrumentation behavior. By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
yiyuan-he
pushed a commit
to yiyuan-he/aws-otel-python-instrumentation
that referenced
this pull request
Dec 12, 2025
…servability#547) *Description of changes:* Ports the changes from open-telemetry/opentelemetry-python-contrib#3990 Add defensive check for Bedrock responses missing expected structure. When no messageStart event with assistant role is received, the response may lack the standard output.message format, causing the occasional KeyError exceptions. For testing, I was unable to reproduce the exact scenario that would trigger this bug, however, this safety check would fix this issue without affecting normal instrumentation behavior. By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
herin049
pushed a commit
to herin049/opentelemetry-python-contrib
that referenced
this pull request
Dec 22, 2025
…#3990) * add defensive check for from_converse response * add defensive check for from_converse response * Update instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/bedrock_utils.py * Update CHANGELOG.md * add comment for malformed repsonses in from_converse * merge suggested changes * fix botocore converse stream test * lint fix * Update instrumentation/opentelemetry-instrumentation-botocore/tests/test_botocore_bedrock.py * add defensive check just in case content doesn't exist in orig_message * lint fix * new line --------- Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
liustve
added a commit
to aws-observability/aws-otel-python-instrumentation
that referenced
this pull request
Feb 4, 2026
Automated update of OpenTelemetry dependencies. **Build Status:** ❌ [failure](https://github.com/aws-observability/aws-otel-python-instrumentation/actions/runs/21465140126) **Updated versions:** - [OpenTelemetry Python](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.39.1): 1.39.1 - [OpenTelemetry Contrib](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.60b1): 0.60b1 - [opentelemetry-sdk-extension-aws](https://pypi.org/project/opentelemetry-sdk-extension-aws/2.1.0/): 2.1.0 - [opentelemetry-propagator-aws-xray](https://pypi.org/project/opentelemetry-propagator-aws-xray/1.0.2/): 1.0.2 **Upstream releases with breaking changes:** Note: the mechanism to detect upstream breaking changes is not perfect. Be sure to check all new releases and understand if any additional changes need to be addressed. **opentelemetry-python:** - [Version 1.35.0/0.56b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.35.0) **opentelemetry-python-contrib:** - [Version 1.34.0/0.55b0](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.55b0) *Description of changes:* - Un-reverts changes done in this PR: #531 - Removed patches for Bedrock following the changes applied in these PRs: open-telemetry/opentelemetry-python-contrib#3544, open-telemetry/opentelemetry-python-contrib#3548, open-telemetry/opentelemetry-python-contrib#3875, open-telemetry/opentelemetry-python-contrib#3990 - Removes patches for Secrets Manager, SNS, and Step Functions following the changes applied in these PRs: open-telemetry/opentelemetry-python-contrib#3734, open-telemetry/opentelemetry-python-contrib#3737, open-telemetry/opentelemetry-python-contrib#3765, - Removes patches for Starlette following the changes applied in this PR: open-telemetry/opentelemetry-python-contrib#3456 - Changes imports and implementation of `OTLPAwsLogExporter`, `AwsCloudWatchOtlpBatchLogRecordProcessor`, and `CompactConsoleLogExporter` following these PRs: open-telemetry/opentelemetry-python#4580, open-telemetry/opentelemetry-python#4535, open-telemetry/opentelemetry-python#4562, open-telemetry/opentelemetry-python#4647, open-telemetry/opentelemetry-python#4676 - Removes a few AWS semantic conventions from `_aws_attribute_keys ` and replaces them with equivalent ones from upstream following the changes in this PR: open-telemetry/opentelemetry-python#4791 - Fix Lambda instrumentation test to set `AWS_LAMBDA_FUNCTION_NAME` env var following changes in: open-telemetry/opentelemetry-python-contrib#3183 - Adds a few more contract tests to verify upstream's botocore instrumentation library By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. --------- Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Thomas Pierce <thp@amazon.com> Co-authored-by: Steve Liu <liustve@amazon.com>
sightseeker
added a commit
to sightseeker/opentelemetry-python-contrib
that referenced
this pull request
Mar 11, 2026
…#3990) * add defensive check for from_converse response * add defensive check for from_converse response * Update instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/bedrock_utils.py * Update CHANGELOG.md * add comment for malformed repsonses in from_converse * merge suggested changes * fix botocore converse stream test * lint fix * Update instrumentation/opentelemetry-instrumentation-botocore/tests/test_botocore_bedrock.py * add defensive check just in case content doesn't exist in orig_message * lint fix * new line --------- Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add defensive check for Bedrock responses missing expected structure. When no messageStart event with assistant role is received, the response may lack the standard output.message format, causing the occasional KeyError exceptions.
Fixes #3958
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
I was unable to reproduce the exact scenario that would trigger this bug , this safety check would fix this without affecting normal instrumentation behavior.
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.