actions / actions/runner

`toJSON` should tolerate properties that are only sometimes available instead of throwing a fatal `Unrecognized named-value`

Open
#2,198 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement Runner Feature
Dominant language
C#
Stars
6.3k
Forks
1.4k
Avg merge
1d 16h
Merged PRs (30d)
24

Description

Describe the bug
Actions need to be able to access contexts and be run regardless of which event a user chooses to use the action.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://github.com/jsoref/community-events/actions/runs/3233269851
Annotations
8 errors

debugjsoref/community-events-action/a/b/c/d/action.yml (Line: 13, Col: 17):

debugjsoref/community-events-action/a/b/c/d/action.yml (Line: 14, Col: 20):
debugjsoref/community-events-action/a/b/c/d/action.yml (Line: 18, Col: 18):
debugjsoref/community-events-action/a/b/c/d/action.yml (Line: 13, Col: 17): Unrecognized named-value: 'jobs'. Located at position 8 within expression: toJSON(jobs || '')Show more
debugjsoref/community-events-action/a/b/c/d/action.yml (Line: 14, Col: 20): Unrecognized named-value: 'secrets'. Located at position 8 within expression: toJSON(secrets || '')Show more
debugjsoref/community-events-action/a/b/c/d/action.yml (Line: 18, Col: 18): Unrecognized named-value: 'needs'. Located at position 8 within expression: toJSON(needs || '')Show more
debugGitHub.DistributedTask.ObjectTemplating.TemplateValidationException: The template is not valid. jsoref/community-events-action/a/b/c/d/action.yml (Line: 13, Col: 17): Unrecognized named-value: 'jobs'. Located at position 8 within expression: toJSON(jobs || ''),jsoref/community-events-action/a/b/c/d/action.yml (Line: 14, Col: 20): Unrecognized named-value: 'secrets'. Located at position 8 within expression: toJSON(secrets || ''),jsoref/community-events-action/a/b/c/d/action.yml (Line: 18, Col: 18): Unrecognized named-value: 'needs'. Located at position 8 within expression: toJSON(needs || '') at GitHub.DistributedTask.ObjectTemplating.TemplateValidationErrors.Check() at GitHub.Runner.Worker.ActionManifestManager.ConvertRuns(IExecutionContext executionContext, TemplateContext templateContext, TemplateToken inputsToken, String fileRelativePath, MappingToken outputs) at GitHub.Runner.Worker.ActionManifestManager.Load(IExecutionContext executionContext, String manifestFile)Show more
debugFail to load jsoref/community-events-action/a/b/c/d/action.yml

Annotations
8 errors
debug
jsoref/community-events-action/a/b/c/d/action.yml (Line: 13, Col: 17):
debug
jsoref/community-events-action/a/b/c/d/action.yml (Line: 14, Col: 20):
debug
jsoref/community-events-action/a/b/c/d/action.yml (Line: 18, Col: 18):
debug
jsoref/community-events-action/a/b/c/d/action.yml (Line: 13, Col: 17): Unrecognized named-value: 'jobs'. Located at position 8 within expression: toJSON(jobs || '')
debug
jsoref/community-events-action/a/b/c/d/action.yml (Line: 14, Col: 20): Unrecognized named-value: 'secrets'. Located at position 8 within expression: toJSON(secrets || '')
debug
jsoref/community-events-action/a/b/c/d/action.yml (Line: 18, Col: 18): Unrecognized named-value: 'needs'. Located at position 8 within expression: toJSON(needs || '')
debug
GitHub.DistributedTask.ObjectTemplating.TemplateValidationException: The template is not valid. jsoref/community-events-action/a/b/c/d/action.yml (Line: 13, Col: 17): Unrecognized named-value: 'jobs'. Located at position 8 within expression: toJSON(jobs || ''),jsoref/community-events-action/a/b/c/d/action.yml (Line: 14, Col: 20): Unrecognized named-value: 'secrets'. Located at position 8 within expression: toJSON(secrets || ''),jsoref/community-events-action/a/b/c/d/action.yml (Line: 18, Col: 18): Unrecognized named-value: 'needs'. Located at position 8 within expression: toJSON(needs || '') at GitHub.DistributedTask.ObjectTemplating.TemplateValidationErrors.Check() at GitHub.Runner.Worker.ActionManifestManager.ConvertRuns(IExecutionContext executionContext, TemplateContext templateContext, TemplateToken inputsToken, String fileRelativePath, MappingToken outputs) at GitHub.Runner.Worker.ActionManifestManager.Load(IExecutionContext executionContext, String manifestFile)
debug
Fail to load jsoref/community-events-action/a/b/c/d/action.yml

Expected behavior
Offer a way to provide a fallback value, e.g. toJSON(x || '')

Runner Version and Platform

Version of your runner? 2.298.2

OS of the machine running the runner? Linux

What's not working?

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.

name: Debug GHA
on:
  branch_protection_rule:
  check_run:
  check_suite:
  create:
  delete:
  deployment:
  deployment_status:
  discussion:
  discussion_comment:
  fork:
  gollum:
  issue_comment:
  issues:
  label:
  member:
  milestone:
  page_build:
  project:
  project_card:
  project_column:
  public:
  pull_request:
  pull_request_review:
  pull_request_review_comment:
  push:
  release:
  repository_dispatch:
  status:
  watch:
  workflow_dispatch:
  workflow_run:
    workflows: [Test]

jobs:
  debug:
    runs-on: ubuntu-latest
    steps:
    - name: set up
      run: |
          echo github.action: ${{github.action}};
          echo github.action_path: ${{github.action_path}};
          echo github.action_ref: ${{github.action_ref}};
          echo github.action_repository: ${{github.action_repository}};
          echo github.actor: ${{github.actor}};
          echo github.api_url: ${{github.api_url}};
          echo github.base_ref: ${{github.base_ref}};
          echo github.env: ${{github.env}};
          echo github.event: ${{github.event}};
          echo github.event_name: ${{github.event_name}};
          echo github.event_path: ${{github.event_path}};
          echo github.graphql_url: ${{github.graphql_url}};
          echo github.head_ref: ${{github.head_ref}};
          echo github.job: ${{github.job}};
          echo github.ref: ${{github.ref}};
          echo github.ref_name: ${{github.ref_name}};
          echo github.ref_protected: ${{github.ref_protected}};
          echo github.ref_type: ${{github.ref_type}};
          echo github.path: ${{github.path}};
          echo github.repository: ${{github.repository}};
          echo github.repository_owner: ${{github.repository_owner}};
          echo github.repositoryUrl: ${{github.repositoryUrl}};
          echo github.retention_days: ${{github.retention_days}};
          echo github.run_id: ${{github.run_id}};
          echo github.run_number: ${{github.run_number}};
          echo github.run_attempt: ${{github.run_attempt}};
          echo github.server_url: ${{github.server_url}};
          echo github.sha: ${{github.sha}};
          echo github.token: ${{github.token}};
          echo github.workflow: ${{github.workflow}};
          echo github.workspace: ${{github.workspace}};
          echo env:;
          env
    - name: debug
      uses: jsoref/community-events-action@a/b/c/d
name: 'Debug'
description: 'Debug'
runs:
  using: composite
  steps:
    - id: debug
      name: debug
      shell: bash
      env:
        x_env: ${{ toJSON(env || '') }}
        x_github: ${{ toJSON(github || '') }}
        x_job: ${{ toJSON(job || '') }}
        x_jobs: ${{ toJSON(jobs || '') }}
        x_secrets: ${{ toJSON(secrets || '') }}
        x_steps: ${{ toJSON(steps || '') }}
        x_runner: ${{ toJSON(runner || '') }}
        x_matrix: ${{ toJSON(matrix || '') }}
        x_needs: ${{ toJSON(needs || '') }}
        x_inputs: ${{ toJSON(inputs || '') }}
      run: |
        echo action-env
        env
        echo
        echo 'objects...'

        cat <<<'EOF'
        github:
        ${{ toJSON(github) }}"

        env:
        ${{ toJSON(env) }}"

        job:
        ${{ toJSON(job) }}"

        jobs:
        {{ toJSON(jobs) }}"

        steps:
        ${{ toJSON(steps) }}"

        runner:
        ${{ toJSON(runner) }}"

        secrets:
        {{ toJSON(secrets) }}"

        strategy:
        ${{ toJSON(strategy) }}"

        matrix:
        ${{ toJSON(matrix) }}"

        needs:
        {{ toJSON(needs) }}"

        inputs:
        ${{ toJSON(inputs) }}"
        EOF

Contributor guide

No contributing guide indexed for this repository

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 reproducing the failure using the linked workflow and action examples, then read the diagnostic log showing validation of toJSON(jobs || ''), toJSON(secrets || ''), and toJSON(needs || ''). Trace how unavailable contexts are resolved and validated. Done means optional contexts no longer cause a fatal Unrecognized named-value error and the reported action can load across the listed events.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
ci-cd, devtools
Issue type
Bug
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.