Skip to content

fix(parameters): accumulate results across chunks in get_parameters_by_name#8002

Closed
abhu85 wants to merge 1 commit intoaws-powertools:developfrom
abhu85:fix/ssm-get-parameters-by-name-chunking-7832
Closed

fix(parameters): accumulate results across chunks in get_parameters_by_name#8002
abhu85 wants to merge 1 commit intoaws-powertools:developfrom
abhu85:fix/ssm-get-parameters-by-name-chunking-7832

Conversation

@abhu85
Copy link

@abhu85 abhu85 commented Feb 23, 2026

Issue # (if applicable)

Closes #7832

Summary

Fixes a variable shadowing bug in _get_parameters_by_name_in_chunks that caused get_parameters_by_name to return only the last chunk of parameters when fetching more than 10 parameters.

Root Cause

In the _get_parameters_by_name_in_chunks method, the loop variable response was being overwritten on each iteration instead of being accumulated:

# Before (buggy):
for chunk in slice_dictionary(data=diff, chunk_size=self._MAX_GET_PARAMETERS_ITEM):
    response, possible_errors = self._get_parameters_by_name(...)  # response overwritten!
    response.update(response)  # No-op: updating dict with itself
    errors.extend(possible_errors)
# After (fixed):
for chunk in slice_dictionary(data=diff, chunk_size=self._MAX_GET_PARAMETERS_ITEM):
    chunk_response, possible_errors = self._get_parameters_by_name(...)
    response.update(chunk_response)  # Accumulate results
    errors.extend(possible_errors)

Impact

When fetching more than 10 parameters with get_parameters_by_name, only the last chunk (up to 10 parameters) was returned. For example, fetching 12 parameters would only return the last 2 parameters instead of all 12.

Changes

  1. aws_lambda_powertools/utilities/parameters/ssm.py: Fixed variable shadowing by renaming the loop variable from response to chunk_response

  2. tests/functional/parameters/_boto3/test_utilities_parameters.py: Added test_get_parameters_by_name_accumulates_results_across_chunks to verify results are accumulated across chunks

Test Plan

  • New test test_get_parameters_by_name_accumulates_results_across_chunks verifies all 12 parameters are returned when fetching more than 10
  • All existing get_parameters_by_name tests pass (16 tests)
  • Ruff linting passes on both modified files

Test Commands

# Run the new test
python -m pytest tests/functional/parameters/_boto3/test_utilities_parameters.py::test_get_parameters_by_name_accumulates_results_across_chunks -v

# Run all related tests
python -m pytest tests/functional/parameters/_boto3/test_utilities_parameters.py -k "get_parameters_by_name" -v

Acknowledgment

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license.

…y_name

Fix variable shadowing bug in _get_parameters_by_name_in_chunks where
the response dict was being overwritten on each loop iteration instead
of being accumulated. This caused get_parameters_by_name to return only
the last chunk of parameters when fetching more than 10 parameters.

Before: response, possible_errors = ... ; response.update(response)
After:  chunk_response, possible_errors = ... ; response.update(chunk_response)

Closes aws-powertools#7832

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: abhu85 <60182103+abhu85@users.noreply.github.com>
@abhu85 abhu85 requested a review from a team as a code owner February 23, 2026 07:41
@abhu85 abhu85 requested a review from anafalcao February 23, 2026 07:41
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Feb 23, 2026
@boring-cyborg boring-cyborg bot added the tests label Feb 23, 2026
@sonarqubecloud
Copy link

@powertools-for-aws-oss-automation

No acknowledgement section found. Please make sure you used the template to open a PR and didn't remove the acknowledgment section. Check the template at .github/PULL_REQUEST_TEMPLATE.md#acknowledgment

@github-actions github-actions bot added the bug Something isn't working label Feb 25, 2026
@dreamorosi
Copy link
Contributor

Superseded by #8006 - this PR is missing required metadata (see failing CI) and the test case was too verbose. I got my own Claude to generate a better one.

Thanks!

@dreamorosi dreamorosi closed this Feb 25, 2026
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: [ssm] cannot get more than 10 parameters

2 participants