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

Inputs context not available in reusable workflows #2206

Closed
pantelis-karamolegkos opened this issue Oct 15, 2022 · 16 comments
Closed

Inputs context not available in reusable workflows #2206

pantelis-karamolegkos opened this issue Oct 15, 2022 · 16 comments
Labels
bug Something isn't working

Comments

@pantelis-karamolegkos
Copy link

pantelis-karamolegkos commented Oct 15, 2022

Describe the bug
The inputs context does not seem available in the with context of reusable workflows

To Reproduce

  • Create a reusable workflow that has the following input
      stg_image_build:
        description: whether to build the staging image
        required: true
        type: boolean
        default: false

Invoke it as follows

  workflow_dispatch:
    inputs:
      push_to_stg:
        description: "Build and push image to staging registry"
        type: boolean
        default: false
        required: true

...

  build-and-push-image:
    needs:
      - echo-input
    uses: Org/repo/.github/workflows/myreusableworkflow.yaml@master
    with:
      stg_image_build: ${{ inputs.push_to_stg }}

Fails

The template is not valid. .github/workflows/calling.yaml (Line: 15, Col: 24): Unexpected type of value '', expected type: Boolean.

Expected behavior
The stg_image_build: ${{ inputs.push_to_stg }} line should be passing to the reusable workflow a boolean.

Runner Version and Platform

GitHub hosted runner

OS of the machine running the runner? OSX/Windows/Linux/...
ubuntu-latest

What's not working?

The template is not valid. .github/workflows/calling.yaml (Line: 15, Col: 24): Unexpected type of value '', expected type: Boolean.
@pantelis-karamolegkos pantelis-karamolegkos added the bug Something isn't working label Oct 15, 2022
@yu-iskw
Copy link

yu-iskw commented Oct 19, 2022

I have a similar issue. I passed a number input to a reusable workflow and it was working well. But, it hasn't been working since 4 hours.

The template is not valid. .github/workflows/validate.yml (Line: 30, Col: 20): Unexpected type of value '', expected type: Number.

@jacob-israel-turner
Copy link

I have a similar issue. I passed a number input to a reusable workflow and it was working well. But, it hasn't been working since 4 hours.

The template is not valid. .github/workflows/validate.yml (Line: 30, Col: 20): Unexpected type of value '', expected type: Number.

I am experiencing the same error. This is when trying to pull a value off of matrix.

@ChristopherHX
Copy link
Contributor

I am experiencing the same error. This is when trying to pull a value off of matrix.

This was a regression and the change has been reverted today: https://github.com/orgs/community/discussions/36670#discussioncomment-3931316

As of today, I cannot reproduce the same issue with the inputs context.

@ruvceskistefan
Copy link
Collaborator

Hey @pantelis-karamolegkos, I'll close this issue since this is not reproducible as @ChristopherHX says. If you are still heaving the same issue feel free to reopen it and we will continue with investigation.

@galcohen-redislabs
Copy link

galcohen-redislabs commented Jan 23, 2023

Still getting a similar error message, using:

jobs:
   ...
   with:
      my_timeout: ${{ inputs.timeout }}

and running gh from the command line like this:
gh workflow run <some-workflow>.yaml --ref <some-branch> -f timeout=300

the result is:

The template is not valid. ....yaml (Line: 15, Col: 20): Unexpected type of value '300', expected type: Number.

@ruvceskistefan FYI

@jtmullen
Copy link

jtmullen commented Apr 12, 2023

@ruvceskistefan I am also still seeing this same issue:

Have a number input via workflow_dispatch that is being directly passed as an input to a reusable workflow:

The template is not valid. .....yml (Line: 29, Col: 23): Unexpected type of value '1', expected type: Number.

@jenseng
Copy link

jenseng commented May 2, 2023

@galcohen-redislabs @jtmullen I ran into a similar issue, it appears that the type gets lost somewhere in the process and those input values become strings. As a workaround, you should be able to use fromJSON to convert them back to the appropriate type (e.g. number, boolean). For example, instead of this:

jobs:
   ...
   with:
      my_timeout: ${{ inputs.timeout }}

give this a try:

jobs:
   ...
   with:
      my_timeout: ${{ fromJSON(inputs.timeout) }} # 🙈 

@galcohen-redislabs
Copy link

@ruvceskistefan Please note the last three comments. The problem still exists.

@ChristopherHX
Copy link
Contributor

ChristopherHX commented Aug 29, 2023

You have a sightly different problem. This was only about type: boolean, which had actually an boolean value before and after this bug report (well it was null in this case, an invalid value).

@galcohen-redislabs Maybe just create a new issue (+ GitHub Support request) about workflow_dispatch ignores type: number and provides a string value in ${{ inputs.<input> }} instead of the expected number?

And Quote that the official GitHub Actions Linter (vscode extention) allows type: number in strict mode, while ignoring it altogether (Ref: https://github.com/actions/languageservices/blob/6513b0d15d5939a285decb5a7584013adc26b392/workflow-parser/src/workflow-v1.0.json#L1490)

if GitHub fixes it, the fromjson workaround should just continue to work as before

EDIT
Actually I don't fully understand why the number/boolean values of reusable workflows inputs are not implicitly convertible from a string.

@Yagya-omnius
Copy link

Could anyone please reopen this issue, it is still reproducible

@pascalro-croesus
Copy link

I get the same problem, for a 'number' input.

@Mikifarber1
Copy link

i got it also, for a "number" input.

@iamutkarshtiwari
Copy link

I am getting the same error.
Starting a new issue.

@act-mreeves
Copy link

@pantelis-karamolegkos - Do you have the following within workflow_call or workflow_dispatch?
I believe it should be under/within workflow_call like shown below.

I think also you would remove default and required since you are always setting the value using "with" from the calling workflow but I may be wrong.

  workflow_call:
    inputs:
      stg_image_build:
        type: boolean

Describe the bug The inputs context does not seem available in the with context of reusable workflows

To Reproduce

  • Create a reusable workflow that has the following input
      stg_image_build:
        description: whether to build the staging image
        required: true
        type: boolean
        default: false

flomnes added a commit to AntaresSimulatorTeam/Antares_Simulator that referenced this issue Dec 29, 2023
flomnes added a commit to AntaresSimulatorTeam/Antares_Simulator that referenced this issue Dec 29, 2023
flomnes added a commit to AntaresSimulatorTeam/Antares_Simulator that referenced this issue Dec 29, 2023
```
The template is not valid. .github/workflows/new_release.yml (Line: 38, Col: 20): Unexpected value 'false'
```


https://github.com/AntaresSimulatorTeam/Antares_Simulator/actions/runs/7357236644

See actions/runner#2206, and more specifically
actions/runner#2206 (comment)
@johnbatclari
Copy link

Unfortunately it doesn't seem like the fromJSON workaound works anymore. Or at least not in my use-case where this is happening with a boolean value.

Either way, this is still very much reproducible as I've just tripped over it. 😉

@mmastrac
Copy link

mmastrac commented Jan 24, 2024

I was able to work around this by using ${{ condition == true }} on the offending line instead of ${{ condition }}

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

17 participants