Repository navigation
fix(parameters): support version and label selectors in get_parameters_by_name - #8620
Conversation
|
Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need. |
leandrodamascena
left a comment
There was a problem hiding this comment.
Thanks @MTirnova, and apologies first: the issue I wrote had the wrong response shape, that's on me. I just ran this against real SSM with a labeled parameter and Selector comes back as only the suffix, ":prod" or ":1", not "/a:prod". So selector in parameters never matches and we fall back to Name. With {"/p:prod": {}, "/p:1": {}, "/p": {}} the result is {"/p": "v1"}: the selector keys disappear and the bare name gets the label's value instead of the latest version.
The fix is simpler than what you have: name = parameter["Name"] + parameter.get("Selector", "") rebuilds exactly the requested key. Could you switch to that and update the stub to the real shape ("Selector": ":prod")? Everything else, the cache under the requested name and the decrypt path, stays as you wrote it. I corrected the issue text too.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #8620 +/- ##
========================================
Coverage 96.93% 96.93%
========================================
Files 318 318
Lines 16072 16072
Branches 1435 1435
========================================
Hits 15580 15580
Misses 349 349
Partials 143 143 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Thanks for checking against real SSM! Switched to |
leandrodamascena
left a comment
There was a problem hiding this comment.
Thanks @MTirnova, that was quick! I re-ran it against real SSM with a labeled version, a plain version and a SecureString, mixing label, version and bare name in the same batch, plus the all-decrypt and the mixed decrypt paths, and every value lands under the key that was requested, from the API and from the cache. Thanks for the extra test with the three selectors together.
Approving now. This goes out in 3.38.0, so it will sit here a bit before I merge. No need to rebase or touch anything, I'll take care of it and you'll get the credit in the release notes. Thank you!
…s_by_name SSM GetParameters returns the bare parameter name in Name and the requested name in Selector when a version or label selector is used (e.g. /a:prod). Looking up Name in the requested parameters raised KeyError. Use Selector when it matches a requested name, for both the response and the cache key.
…suffix SSM returns only the selector suffix (e.g. ":prod") in Selector, not the full requested name. Rebuild the key as Name + Selector, and update the test stubs to the real response shape: no Selector for names requested without one, and only the suffix otherwise.
7b57d1f to
e1b292b
Compare
|



Issue number: closes #8587
Summary
Changes
When a parameter name includes a version or label selector (
/a:prod,/a:3), SSMGetParametersreturns the bare name inNameand the requested name inSelector._transform_and_cache_get_parameters_responselooked upNamein the requested parameters, soget_parameters_by_nameraisedKeyError: '/a'.Selectoras the key when it matches a requested name, otherwise fall back toName. The same key is used for the response, the cache key and the transform error key.get()per parameter.decrypt=False/True) and for the cache: a second call for the same selector is served from the cache under the requested name.The new tests fail on
developwith theKeyErrorfrom the issue and pass with this change.tests/functional/parameterspasses (141 tests), andruffandmypyare clean for the changed files.User experience
Before:
After:
This matches
provider.get("/a:prod"), which already worked.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.