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.

Validate required inputs are set before invoking an action

See original GitHub issue

Describe the bug

I have the following action.yml:

name: 'Anka Prepare VM and execute inside'
description: 'Prepare an Anka VM and execute commands inside'
author: Veertu
branding:
  icon: 'anchor'
  color: 'blue'
inputs:
  anka-template:
    description: 'name or UUID of Anka Template'
    required: true

My index.js looks like:

const core = require('@actions/core');
const io = require('@actions/io');
const prepare = require('./prepare');
const execute = require('./execute');

// most @actions toolkit packages have async methods
async function run() {
  try { 
    const ankaVirtCLIPath = await io.which('anka', true)
    console.log(`Anka Virtualization CLI found at: ${ankaVirtCLIPath}`)
    const ankaTemplate = core.getInput('anka-template');
    const ankaTag = core.getInput('anka-tag');
    const ankaCommands = core.getInput('commands');
    const hostPreCommands = core.getInput('host-pre-commands');
    const hostPostCommands = core.getInput('host-post-commands');
    console.log("=========================" + "\n" + `${hostPreCommands}` + "\n" + "=================================")
    console.log("=========================" + "\n" + `${hostPostCommands}` + "\n" + "=================================")
    console.log("=========================" + "\n" + `${ankaCommands}` + "\n" + "=================================")
    if (hostPreCommands) {
      await execute.nodeCommands(hostPreCommands)
    }
    // Prepare VM
    await prepare.ankaRegistryPull(ankaTemplate,ankaTag)
    // Run commands inside VM
    // Cleanup
    if (hostPostCommands) {
      await execute.nodeCommands(hostPostCommands)
    }
  } catch (error) {
    core.setFailed(error);
  }
}

run()

and finally, the important part of my .github/workflows/test.yml:

    - name: basic commands
      id: basic
      uses: ./
      with:
        commands: |
          env
          ls -laht ./
          ls -laht ../
          pwd
          echo "HERE" && \
          echo "THERE HERE WHERE"

Yet, there is no failure for missing anka-template… It fails for a reason inside of the ankaRegistryPull function which is well after it tries to load the input.

https://help.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#inputs seems to indicate that it shouldn’t allow the action to run if it’s missing that input.

What am I missing?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:48
  • Comments:20

github_iconTop GitHub Comments

37reactions
anukulcommented, Aug 12, 2021

So what’s the point of required? 🤔

14reactions
aggenebbisjcommented, Jan 14, 2021

I just ran into the same issue. Have to say it’s quite unexpected to mark something as required and then finding out it blows up silently. Especially since toolkit is the official GitHub toolkit for actions.

we could also fail the step if the required inputs are not set.

I think this would make a lot of sense 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why are required inputs to GitHub Actions not enforced?
1 Answer. Currently GitHub does not check if required input has been passed. This is being tracked in this issue. However, you can...
Read more >
Validating Input | Web Accessibility Initiative (WAI)
Validating required input ​​ Forms frequently include required input that needs to be clearly identified using labels. Also, the required attribute can be...
Read more >
How to Validate Forms in React – A Step-By-Step Tutorial ...
We will implement input validation using react-hook-form, which will ensure that the data entered by users is valid before it is submitted.
Read more >
Input Validation - Adaptive Cards
Inputs will be validated when the user clicks on an Action.Submit action in the card. Those inputs which will be validated and submitted...
Read more >
Apps - Use Required Input Validation
You can use required input validation to notify the user in runtime that input to a control is mandatory by setting the Required...
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