toolkit icon indicating copy to clipboard operation
toolkit copied to clipboard

[core] getInput returns empty string

Open EnbyAce opened this issue 4 years ago • 8 comments

Describe the bug core.getInput("username") returns an empty string while username is required and has been set.

To Reproduce Steps to reproduce the behavior:

  1. Create a JavaScript action with username as required input (also actually give the input in a workflow)
  2. Access the username input anywhere in the code with const core = require("@actions/core"); and core.getInput("username");
  3. It returns an empty string

Expected behavior core.getInput("username") to return the value I've given in a workflow, which in my case is AceKiron

Workflow runner (please complete the following information):

  • OS: Ubuntu
  • Version Latest

EnbyAce avatar May 14 '22 11:05 EnbyAce

Nevermind, am just dumb.

EnbyAce avatar May 14 '22 19:05 EnbyAce

could you give the solution Im facing same problem

DeployIsComing avatar Aug 11 '22 17:08 DeployIsComing

Unfortunately I don't remember the solution, perhaps it was some misspelling?

EnbyAce avatar Aug 11 '22 17:08 EnbyAce

I wish it was a misspelling

I even tried with required flag.... always returning empty core.getInput('procedure', { required: true })

DeployIsComing avatar Aug 11 '22 17:08 DeployIsComing

Interesting, could you show me your action.yml file?

EnbyAce avatar Aug 11 '22 17:08 EnbyAce

I'm running into the same thing, core.getInput('value') returns empty string, while ${{ inputs.value }} correctly gives me the input value of my action. :shrug:

topaxi avatar Jul 24 '23 09:07 topaxi

I keep getting this error when I use github-script. I figured it could be that getInput refers to the inputs the actions/github-script gets and not the inputs of the workflow where I use it. Quite misleading in this context, because we can't set inputs to this predefined action ourselves and reading the inputs defined for this action doesn't make sense for most users. Then again, the JS library was created mainly for writing custom actions and github-script is just a shorthand.

I only wish that this method would throw an error by default instead of pretending that an empty string is fine.

pawkubik avatar Nov 12 '24 10:11 pawkubik

It looks like @pawkubik is right. core.getInput refers to the inputs of the step, not of the workflow. The following returned "warning: unexpected input" but worked. name: DEBUG Execute checks and update PRs

on:
  workflow_dispatch:
    inputs:
      branch:
        type: string
        default: 'dev'

jobs:
  update_prs:
    runs-on: ubuntu-latest

    steps:
...
      - name: Set check runs on submodule PRs
        uses: actions/github-script@v7
        with:
          branch: ${{ inputs.branch }}
          script: |
            const branchToMatch = core.getInput('branch');

svinopterix avatar Aug 07 '25 14:08 svinopterix