fix: Avoid failure if a handler argument is provided to the lambda #99
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
This PR adds a workaround for some unexpected behaviour in the combination of LocalStack and
clap
which can cause environment variable parsing to fail when running Image based lambdas in LocalStack.Why
When running Image based lambdas in LocalStack, I observed that a command line argument of
handler.handler
was being provided to the rust binary process. I need to further investigate how/why this is being passed in. I believe it to be a bug, but I haven't confirmed that.This command line value was in turn parsed by
clap
as part of our environment parsing. The behaviour ofclap
was to assign this command line value to the first element of theEnv
struct, and then ignore any environment variable provided for that element. This caused the wrong value to be provided to theEnv
struct (although it was considered valid, as my use case expected aString
value for this first element). The code would then attempt to parse theHandlerEnv
, at which point it would fail, asHandlerEnv.record_concurrency
is ausize
value, which cannot be parsed from a string.This PR works around this situation by always passing an empty iterator to
Env::try_parse_from()
, since we never care about any command line arguments anyway.