question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mixed `${{ inputs }}` reusable workflow and caller workflow

See original GitHub issue

Describe the bug The inputs between workflow_call and workflow_dispatch are unified (https://github.blog/changelog/2022-06-10-github-actions-inputs-unified-across-manual-and-reusable-workflows/). However, I found a corner case that seems to behave incorrectly. When a workflow runs on workflow_dispatch event and calls a reusable workflow, the reusable workflow’s inputs contain not only its defined inputs, but also the calling workflow’s inputs (from the dispatch event)

To Reproduce

  1. Create workflow.yml:
on:
  workflow_dispatch:
    inputs:
      release-tag:
        description: "Release tag to test"
        required: false
        default: v1
        type: string
  
jobs:
  release:
    permissions:
    uses: <repo>/<name>/.github/workflows/reusable.yml@main
    with:
      name1: value1
  1. create reusable workflow:
on:
  workflow_call:
    inputs:
      name1:
        description: "name 1"
        required: true
        type: string

jobs:
  test:
    outputs:
    runs-on: ubuntu-latest
    steps:
      - run: |
         echo "inputs: ${{ inputs }}"

This will show both the name1 and release-tag, even though the input to the reusable workflow has only one input defined (name1).

Expected behavior Only the name1 input should show.

Runner Version and Platform

Version of your runner?

ubuntu-latest

What’s not working?

Please include error messages and screenshots.

Job Log Output

If applicable, include the relevant part of the job / step log output here. All sensitive information should already be masked out, but please double-check before pasting here.

Runner and Worker’s Diagnostic Logs

If applicable, add relevant diagnostic log information. Logs are located in the runner’s _diag folder. The runner logs are prefixed with Runner_ and the worker logs are prefixed with Worker_. Each job run correlates to a worker log. All sensitive information should already be masked out, but please double-check before pasting here.

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:15 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
ChristopherHXcommented, Mar 6, 2023

Non authoritative workaround, as implemented in my GitHub Actions Emulator in my fork of this runner.

How can we reliably distinguish them?

Remove all inputs not defined in the same workflow file.

  • pass ${{ tojson(inputs) }} to a step
  • make the oidc call
  • Use oidc.job_workflow_ref and oidc.job_workflow_sha (sha is important otherwise the file could have changed) to download the current reusable workflow
  • remove all inputs not defined in the on.workflow_call.inputs mapping as key

Why does this work?

when A calls B and B calls C, that is, A - B - C

  • A has only workflow_dispatch inputs
  • B has all workflow_call directly passed to it + defaults for not passed inputs, all inputs not declared in the on.workflow_call.inputs section are filled up by workflow_dispatch inputs
  • C has all workflow_call directly passed to it + defaults for not passed inputs, all inputs not declared in the on.workflow_call.inputs section are filled up by workflow_dispatch inputs (No inputs of Workflow B are present)

That was actually our intention to include both calling workflow’s input and reusable workflow’s input

I think you actually mean “That was actually our intention to include both workflow_dispatch’s input and reusable workflow’s input”. Calling workflow’s input would imply inputs of workflow B leak into workflow C, this is not the case.

0reactions
Makpersoncommented, Apr 21, 2023

Hi,

Are there any updates on that? I’ve checked and it looks like it’s still working like that. Which is kind of funny, because this way, when I run the reusable workflow “By itself” it’s gonna fail due to no input.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can I create a caller workflow with on.manual_dispatch ...
I have a reusable workflow that uses input.choice (and other inputs) which will likely need to change again and again. This workflow is ......
Read more >
Add Inputs to GitHub Actions Workflows - YouTube
In this GitHub Actions Tutorial, we'll walk through how to add user inputs to workflow_dispatch triggers in your GitHub Actions workflow so ...
Read more >
Avoid Duplication! GitHub Actions Reusable Workflows
Right, let's see how to create a reusable workflow. ... The inputs are used to pass normal data (aka not sensitive information):.
Read more >
How to start using reusable workflows with GitHub Actions
Reusable workflows offer a simple and powerful way to avoid copying and pasting workflows across your repositories.
Read more >
Manually Trigger GitHub Actions Workflows
A workflow_dispatch trigger can support multiple inputs at the same time; and we can mix-and-match input types. In the following example, we'll ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found