Description
Use case
Fetching a non-existing parameter usually results in an error from sdk (not sure about every provider secrets/appconfig etc). Not receiving a param usually block an execution flow. If developers need to, they can account for such errors and do some actions on catch.
However, since powertools parameters utility uses Map for caching, it is by default typed to be T | undefined, even though it's the utility that is responsible for adding the parameter to the map, and it can guarantee if something has indeed been added to the Map. Hence, is it possible to return NonNullable in the get method of the params util? If it's not a desirable maybe with throwOnUndefined option?
This would greatly reduce boilerplate of checking if the returned param is not undefined or throwing an error otherwise.
Solution/User Experience
Return NonNullable for get method of the params utilities.
Alternative solutions
Acknowledgment
- This feature request meets Powertools for AWS Lambda (TypeScript) Tenets
- Should this be considered in other Powertools for AWS Lambda languages? i.e. Python, Java, and .NET
Future readers
Please react with 👍 and your use case to help us understand customer demand.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status