Skip to content

Feature request: NonNullable return type for parameters #4086

Open
@artkhod

Description

@artkhod

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

Future readers

Please react with 👍 and your use case to help us understand customer demand.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestThis item refers to a feature request for an existing or new utilityneed-more-informationRequires more information before making any callsparametersThis item relates to the Parameters Utility

    Type

    No type

    Projects

    Status

    Ideas

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions