Bugfix: Invalid values for grouped arguments via environment variables are not handled #239
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.
Grouped CLI arguments that can be also defined via environment variables (not just CLI switches) can cause unexpected exceptions when invalid values are provided as environment variable value.
For example action
app-store-connect publish
has argument group "Apple's altool configuration options" that contains switch--altool-retries
, which is supposed to be a positive integer. Its value can also be specified by environment variableAPP_STORE_CONNECT_ALTOOL_RETRIES
. It is expected that the same values either from CLI or from environment yield in exactly the same result, but it is not the case as of now. Invalid values from CLI args are handled properly$ app-store-connect publish --path app.ipa --altool-retries -1 usage: app-store-connect publish [-h] [--log-stream {stderr,stdout}] [--no-color] [--version] [-s] [-v] [--path artifact-path [artifact-path ...]] ... app-store-connect publish: error: argument --altool-retries: Provided value "-1" is not valid
while the same value from respective envirionment variable results in an unhandled exception:
with full exception traceback being
This happens because the mechanism that copies duplicates argument instance with custom group had a fault that did not persist the
argparse
registered argument access. In this PR parser argument access is reworked in a way that the original argument is registered as a CLI argument, and duplicate reuses the parser argument from original when need be.