actions / actions/toolkit

core.getInput does not tell the caller if the returned value is defined in the yaml or not

Open
#272 4 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

core enhancement papercut
Dominant language
TypeScript
Stars
5.9k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

Describe the enhancement
core.getInput() should allow the caller to understand whether the value is explicitly set in the yaml file, or whether it is not.
Right now you get an empty string, either when it is not defined, either when the user defined it as an empty string.

Code Snippet

this would allow this code:

const inputValue = core.getInput(inputName) ?? defaultValue;

Right now you have to use this instead:

const inputValue = core.getInput(inputName) || defaultValue;

which is not the same.

Use case
e.g. An action's input is a string which is a list of flags, if the default is "-v" and the user wants to have no flags at all (e.g. flags: ""), having this explicitly stated as input (e.g. flags: "") would be always (uncorrectly) replaced by the default (when using ||). To overcome this the user is forced to define a in the yaml the input as blank space instead (e.g. flags: " ")

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the core.getInput entry point and its current return contract. Determine how callers can distinguish an absent value from an explicitly empty one without losing the use case described, then verify the behavior for missing, empty, and non-empty inputs before considering the issue done.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, developer-experience
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.