Open dreamorosi opened 1 week ago
From the BelieveInServerless Discord server, a customer was having issues while passing a value typed as any
which at runtime was a number
and that caused the same behavior described above.
Another +1 for runtime validation.
Ok, let's do it 🙂
Expected Behavior
When adding a dimension to my metrics, I should get a warning if the dimension value is invalid aka an empty string (
""
) orundefined
/null
, and the dimension should not be added to the EMF blobs emitted by the utility.Current Behavior
Currently the utility doesn't validate the input but only enforces types. In practice this means it's unlikely customers can pass
undefined
ornull
unless they're suppressing the warning, but can pass an empty string and generate an EMF blob that will have the invalid dimension.Code snippet
Steps to Reproduce
Possible Solution
We should: 1/ validate the input when adding a dimension, 2/ emit a warning if invalid, and 3/ don't add the dimension to the EMF blob
Powertools for AWS Lambda (TypeScript) version
latest
AWS Lambda function runtime
20.x
Packaging format used
npm
Execution logs