generated from amazon-archives/__template_MIT-0
-
Notifications
You must be signed in to change notification settings - Fork 464
Open
Labels
bugSomething isn't workingSomething isn't workingtriagePending triage from maintainersPending triage from maintainers
Description
Expected Behaviour
Follow the example in https://docs.aws.amazon.com/powertools/python/latest/utilities/parameters/#fetching-parameters, when call get_parameters_by_name with more than 10 existed parameters, it should return all those parameters.
Current Behaviour
Return only the last chunk of parameters
Code snippet
from aws_lambda_powertools.utilities.parameters import ssm
params = {
"/dev/param1": {},
"/dev/param2": {},
"/dev/param3": {},
"/dev/param4": {},
"/dev/param5": {},
"/dev/param6": {},
"/dev/param7": {},
"/dev/param8": {},
"/dev/param9": {},
"/dev/param10": {},
"/dev/param11": {},
"/dev/param12": {},
}
response, errors = ssm.get_parameters_by_name(params)
print("Final fetched parameters:", response)
# Actual results: only param11, param12 returned
# Expected results: all params returnedPossible Solution
Bug in method _get_parameters_by_name_in_chunks
powertools-lambda-python/aws_lambda_powertools/utilities/parameters/ssm.py
Lines 572 to 594 in a104ede
| def _get_parameters_by_name_in_chunks( | |
| self, | |
| batch: dict[str, dict], | |
| cache: dict[str, Any], | |
| raise_on_error: bool, | |
| decrypt: bool = False, | |
| ) -> tuple[dict, list]: | |
| """Take out differences from cache and batch, slice it and fetch from SSM""" | |
| response: dict[str, Any] = {} | |
| errors: list[str] = [] | |
| diff = {key: value for key, value in batch.items() if key not in cache} | |
| for chunk in slice_dictionary(data=diff, chunk_size=self._MAX_GET_PARAMETERS_ITEM): | |
| response, possible_errors = self._get_parameters_by_name( | |
| parameters=chunk, | |
| raise_on_error=raise_on_error, | |
| decrypt=decrypt, | |
| ) | |
| response.update(response) | |
| errors.extend(possible_errors) | |
| return response, errors |
The response variable in line 580 is overridden by the line 586
Steps to Reproduce
See the code snippet
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.13
Packaging format used
PyPi
Debugging logs
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingtriagePending triage from maintainersPending triage from maintainers
Type
Projects
Status
Triage