-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Describe the bug
As a GitHub Actions author, it is impossible to tell the difference between an unsupplied input and an input set to the empty string.
There is no way for me, as an Actions author, to tell the difference between these two user-supplied workflows:
steps:
- uses: 'foo/bar'
with:
my_value: ''and
steps:
- uses: 'foo/bar'In both instances, core.getInput('my_value') will result in the empty string, even though the second instance is explicitly null. Even explicitly setting the value to null results in the value being set to the empty string:
steps:
- uses: 'foo/bar'
with:
my_value: ~This is problematic when mixed with GitHub secrets, because when secrets are not available (such as from a fork), they are injected as they wind up appearing as the empty string. This makes it impossible to distinguish between an unsupplied input and an input set to the empty string.
The primary use case is around providing a more informative error to the end user. In the case where the input is completely missing, this is a "syntax error" (the user needs to fix their workflow file). However, in situations where the input exists but has a value of the empty string, we can hint toward other possibilities (such as secrets injection or missing envvars), because it's highly unlikely someone would actually use the empty string as a value (it's most likely coming from some interpolation that's secretly failing).
I know inputs are actually transformed envvars, so I explored trying to read process.env directly in google-github-actions/auth#54. Normally something like the following would work:
const hasValue = `INPUT_MY_VALUE` in process.env;However, it appears that GitHub Actions initializes all inputs to the empty string, even when they are explicitly not given. Furthermore, even when I set a default value of ~ (null) in the Actions metadata file, the environment variable value is still set to the empty string. This makes it impossible to distinguish between "no value given" and "value is the empty string".
Expected behavior
There should be a way to determine if a value was given.
Screenshots
- N/A
Desktop (please complete the following information):
- N/A
Smartphone (please complete the following information):
- N/A
Additional context
Add any other context about the problem here.