Skip to content

fix(bedrock_agent): fix querystring field resolution #6777

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

Conversation

matteofigus
Copy link
Member

Issue number: #6520

Summary

Changes

This PR fixes an issue where Bedrock Agent parameters containing commas (like SQL queries) were being truncated because the method was splitting them by commas.

The fix overrides the method in the class to preserve parameter values without splitting them by commas. This ensures that parameters like SQL queries with commas are correctly passed to the handler function.

Added unit and functional tests to verify the fix works correctly.

User experience

Before:
When using a Bedrock Agent with parameters containing commas (like SQL queries), only the part before the first comma was being passed to the handler function.

For example, with a parameter value of "SELECT a.source_name, b.thing FROM table", only "SELECT a.source_name" would be passed to the handler.

After:
The entire parameter value is correctly passed to the handler function, including any commas.

For example, with a parameter value of "SELECT a.source_name, b.thing FROM table", the entire string is passed to the handler.

Checklist

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

This fixes issue aws-powertools#6520 where Bedrock Agent parameters containing commas (like SQL queries) were being truncated because the resolved_query_string_parameters method was splitting them by commas.

The fix overrides the resolved_query_string_parameters method in the BedrockAgentEvent class to preserve parameter values without splitting them by commas.
@matteofigus matteofigus requested a review from a team as a code owner June 5, 2025 23:44
@boring-cyborg boring-cyborg bot added the tests label Jun 5, 2025
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 5, 2025
@github-actions github-actions bot added the bug Something isn't working label Jun 5, 2025
Copy link

codecov bot commented Jun 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.13%. Comparing base (e1e0f32) to head (46b8147).
Report is 3 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #6777      +/-   ##
===========================================
- Coverage    96.15%   96.13%   -0.02%     
===========================================
  Files          256      256              
  Lines        12350    12354       +4     
  Branches       916      916              
===========================================
+ Hits         11875    11877       +2     
- Misses         373      375       +2     
  Partials       102      102              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@leandrodamascena leandrodamascena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @matteofigus, thanks for submitting this PR! This solves the problem for BedrockResolver, but in other resolvers where we have multiquerystring fields, we have the same problem. For example, if you replace Bedrock Resolver with APIGatewayHttpResolver (of course, changing the payload), you will observe the same problem.

So, with that said, do you want to open a new issue to investigate other resolvers or do you want to address the issue in this same PR? I would prefer the second option, but feel free to make your own decision.

- Change @cached_property to @Property for resolved_query_string_parameters
- Simplify the functional test by directly returning the query parameter
- Remove redundant unit test
@leandrodamascena leandrodamascena changed the title fix: prevent splitting Bedrock Agent parameters with commas fix(bedrock_agent): fix querystring field resolution Jun 6, 2025
Copy link
Contributor

@leandrodamascena leandrodamascena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @matteofigus! APPROVED

Copy link

@leandrodamascena leandrodamascena merged commit c94accc into aws-powertools:develop Jun 10, 2025
11 of 12 checks passed
@matteofigus matteofigus deleted the fix-bedrock-agent-comma-parameters branch June 10, 2025 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Powertools Bedrock Resolver truncates parameters with commas
2 participants