Skip to content

feat: Check if action run hasInput#849

Draft
shrink wants to merge 2 commits intoactions:mainfrom
shrink:feature-has-input
Draft

feat: Check if action run hasInput#849
shrink wants to merge 2 commits intoactions:mainfrom
shrink:feature-has-input

Conversation

@shrink
Copy link

@shrink shrink commented Jun 21, 2021

I am trying to determine if an input has been provided in an action where an empty string is a valid value, unfortunately an empty string is treated the same as no input by getInput. I would ideally like to change getInput to distinguish between "no value" and "empty value" but that would be a breaking change: the introduction of hasInput is a safe middle-ground that enables this determination without any breaking changes.


An alternative I considered was introducing a default to InputOptions which would help bring InputOptions and action.yml in line but I think that introduces more questions (should trimWhitespace be an option in action.yml?) so I went for the simpler option.

@shrink
Copy link
Author

shrink commented Jun 26, 2021

unfortunately, it turns out this doesn't work, because of the runner: https://github.com/actions/runner/blob/be9632302ceef50bfb36ea998cea9c94c75e5d4d/src/Runner.Worker/ActionRunner.cs#L189-L202

// Merge the default inputs from the definition
if (definition.Data?.Inputs != null)
{
    var manifestManager = HostContext.GetService<IActionManifestManager>();
    foreach (var input in definition.Data.Inputs)
    {
        string key = input.Key.AssertString("action input name").Value;
        validInputs.Add(key);
        if (!inputs.ContainsKey(key))
        {
            inputs[key] = manifestManager.EvaluateDefaultInput(ExecutionContext, key, input.Value);
        }
    }
}

I will try investigate further if it's possible to achieve this in a different way.

@shrink shrink marked this pull request as draft June 26, 2021 00:24
@shrink
Copy link
Author

shrink commented Jun 26, 2021

Acknowledged as a bug in actions/runner#924. I'll PR a fix for that and then bring this back.

Edit: #1176

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants