Repository navigation
Conversation
|
leandrodamascena
left a comment
There was a problem hiding this comment.
Thanks @SumiRann1, the two places you changed are the right ones. Problem is #8619 landed while this was open and changed the key shape again, so this needs an update.
SSMProvider.get() always passes decrypt in sdk_options, so its key on develop today is (name, transform, False, '{"decrypt": false}'). Your batch key is (name, transform, False). Still different, and your two new tests fail after a rebase. Pass sdk_options={"decrypt": options["decrypt"]} to _build_cache_key in both spots and fix the expected key in test_get_parameters_by_name_cache. I tried it locally against real Parameter Store and both directions share the cache after that.
This also fixes something worse I noticed while testing: the batch path caches a SecureString under the same key with or without decrypt, so a second batch call without decrypt gets the decrypted value from cache. Please add a test for that: two batch calls, one with decrypt=True, one without, both must hit the API.
Rebase on develop too, the conflict is only in the test file, keep both blocks. Ping me when it's ready. This is in 3.39.0.



Issue number: closes #8593
Summary
Changes
get_parameters_by_namebuilt its cache key by hand as(name, transform)in_get_parameters_by_name_from_cacheand_transform_and_cache_get_parameters_response, whileBaseProvider._build_cache_key(used byget()) builds(name, transform, is_nested). The two never matched, so the same parameter was fetched twice and stored twice.This PR uses
self._build_cache_key(...)in both places inssm.py, soget()andget_parameters_by_nameshare cache entries. Parameters that go through the decrypt path (which callsget()) are now also found in the cache by the batch path.I added two regression tests (
get()thenget_parameters_by_name, and the other way around) and updatedtest_get_parameters_by_name_cache, which hardcoded the old key shape(name, None).User experience
Before: a parameter fetched with
get("/a")was fetched again by a followingget_parameters_by_name({"/a": {}})even though it was still fresh in cache (extra API call, duplicate cache entry), and vice versa.After: the fresh cached value is reused in both directions.
Checklist
uv run pytest tests/functional/parameters)ruff formatandruff checkpassBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.