Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getBooleanInput ignores options.required #844

Open
RA80533 opened this issue Jun 14, 2021 · 7 comments
Open

getBooleanInput ignores options.required #844

RA80533 opened this issue Jun 14, 2021 · 7 comments
Labels
bug Something isn't working

Comments

@RA80533
Copy link

RA80533 commented Jun 14, 2021

Describe the bug

  1. Calling getBooleanInput to read an unset input
  2. Calling getBooleanInput with { required: false } to read an unset input throws an error

Expected behavior
getBooleanInput should function the same as getInput in the following ways:

  • It respects options.required
  • Inputs are not required by default
@rethab
Copy link
Contributor

rethab commented Mar 4, 2022

For future visitors, this issue was discussed when the getBooleanInput function was added and it was decided against (signed off by @thboop):

the function is used to deal with boolean input, It should have a default value in action.yml if it is not necessary

ref: #725 (comment)

However, imo since this function does accept a flag required, it is very surprising that this is not respected. Defaulting to false seems like a sensible default to me.

I'd be happy to contribute a PR for this if you agree @thboop

boneskull added a commit to boneskull/nodejs-production-test-action that referenced this issue Jun 8, 2022
@yi-Xu-0100
Copy link
Contributor

yi-Xu-0100 commented Sep 20, 2022

In the getBooleanInput function, it uses getInput to get the value from action. The required: false will be dealt with the getInput and return the default value. 👀

Could you provide a simple reproducing repository?

@RomainMuller
Copy link

RomainMuller commented Sep 27, 2022

actions/setup-dotnet@v2 used to work without passing include-prerelease to it until yesterday...

Today, I get this:

Run actions/setup-dotnet@v2
  with:
    dotnet-version: 3.1.x
  env:
    DOTNET_NOLOGO: true
    NODE_OPTIONS: --max-old-space-size=4096
Error: Input does not meet YAML 1.2 "Core Schema" specification: include-prerelease
Support boolean input list: `true | True | TRUE | false | False | FALSE`

This appears to have been broken recently (although it's not clear to me how actions/setup-dotnet updates their dependency on actions/tooklit).

According to the code, the actions/setup-dotnet@v2 action actually has a default of false since 2 months ago (so setting a default does not save you here): https://github.com/actions/setup-dotnet/blob/a351d9ea84bc76ec7508debf02a39d88f8b6c0c0/action.yml#L21


Update: I just realized my actions/setup-dotnet had the following clause:

include-prerelease: ${{ matrix.dotnet-prerelease }}

While there was no setting for dotnet-prerelease in the matrix, resulting in the value being explicitly undefined. This might be the cause of the problem I'm observing (the behavior nevertheless changed very recently, but I'm willing to consider it is my fault and this only accidentally worked before).

@Relequestual
Copy link

This is also problematic when trying to run tests for your action, as you have to manually set inputs via envrionment.
I've defined a default in action.yaml, but it has no impact when running tests.

@Vampire
Copy link

Vampire commented Jul 7, 2023

That has nothing to do with the issue here which is about "required" being ignored, does it?

@Relequestual
Copy link

That has nothing to do with the issue here which is about "required" being ignored, does it?

I think it does actually. The argument above was saying you could provide a default in the YAML for the action, but you can't do that when the YAML isn't being used.

I was providing a different use case where the workaround isn't valid.

SevereCloud added a commit to VKCOM/gh-actions that referenced this issue Sep 6, 2023
Исправленная версия getBooleanInput функции из `@actions/core`

- actions/toolkit#844
SevereCloud added a commit to VKCOM/gh-actions that referenced this issue Sep 6, 2023
Исправленная версия getBooleanInput функции из `@actions/core`

- actions/toolkit#844
bakerkretzmar added a commit to bakerkretzmar/laravel-deploy-preview that referenced this issue May 31, 2024
@LittleColin
Copy link

I see this issue is now pretty old and no one is addressing it - this is a particularly annoying one for us as we are using two approaches to check our action changes aren't going to break CIs and neither picked up on this because:

  1. https://github.com/rhysd/actionlint correctly doesn't mind an optional boolean parameter without a default
  2. unit tests mocked out the getBooleanInput so masked the problem

So now we're going to write another "validator" because this hasn't been fixed to ensure that all boolean inputs have a default value if not required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants