fix: Do not merge missing default value into Action inputs#1176
Open
shrink wants to merge 1 commit intoactions:mainfrom
Open
fix: Do not merge missing default value into Action inputs#1176shrink wants to merge 1 commit intoactions:mainfrom
shrink wants to merge 1 commit intoactions:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #924
At present, an Input without a default value is given a default value of an empty string, meaning there's no way for Action authors to differentiate between "no value was provided" and "an empty string was provided". As described in #924, this introduces a number of challenges for Action authors and has been acknowledged as a (low priority) bug.
The change in this Pull Request is very simple: do not set a default string value when no default is provided -- using a
NullTokeninstead of aStringToken. As a consequence, theINPUT_*environment variables will now only contain a value when an input or default is provided.Backwards Compatibility
The GitHub Actions toolkit package
coreprovides agetInputmethod which checks for the presence of the environment variable and uses a default empty string if the environment variable is not found, therefore this change would not break the behaviour of the toolkit. However, it would enable the introduction ofhasInputas described in my Pull Request feat: Check if action run hasInput #849.https://github.com/actions/toolkit/blob/45647689407e7fb224e06d066dde6aefa67a365f/packages/core/src/core.ts#L80-L101
I've performed various tests of this against my own actions (like actions-assert) and experienced no issues, so I'm fairly confident in saying it works without issue.
Previously
action.ymlWith this change
action.yml$ printenv INPUT_EXAMPLE