Fix AWS Bedrock ARN parsing issue in converse methods #544
+3
−3
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
Fixes AWS Bedrock instrumentation crash when using ARN or cross-region model IDs that contain multiple dots. The issue occurred in
patch_converse_stream
andpatch_converse
functions wheremodelId.split(".")
assumed exactly 2 parts, but ARNs and cross-region IDs have multiple dots, causingValueError: too many values to unpack (expected 2)
.Problem:
Solution:
Replaced the problematic split calls with the existing robust
parse_vendor_and_model_name_from_model_id()
function that already handles ARNs correctly and is used consistently in other methods likepatch_invoke_model
.Changes Made
(vendor, _) = modelId.split(".")
withvendor, _ = parse_vendor_and_model_name_from_model_id(modelId)
inpatch_converse_stream
patch_converse
functionKey Review Points
Test with actual ARN formats: The existing test suite covers the parser function, but please test the full instrumentation pipeline with:
arn:aws:bedrock:us-east-1:<account_id>:inference-profile/us.anthropic.claude-3-haiku-20240307-v1:0
us.anthropic.claude-sonnet-4-20250514-v1:0
Behavioral consistency: Confirm that
parse_vendor_and_model_name_from_model_id()
returns compatible values for all model ID formats that the original split logic handledRun existing test suite: I couldn't run the full test suite locally due to missing dependencies, so please verify no regressions with:
Testing Evidence
Created test script that reproduces the original error:
Checklist for bug fix:
Link to Devin run: https://app.devin.ai/sessions/9b326f6380504040bf8b711ce512ab94
Requested by: karthik@scale3labs.com
Risk Assessment: Low-risk change (2 lines) but affects core functionality. The existing parser is well-tested, but human verification of compatibility is essential since I couldn't run the full test suite locally.