Skip to content

fix(release): release pr merge step fails when pr output is empty #2616

Closed

Description

@dan-petty

Problem Description

Workflow run 40812475380 on main failed in job Release Please at step Merge the Release Pull Request on an Urgent Fix.
The step environment variable RELEASE_PR: ${{ fromJSON(steps.release.outputs.pr).number }} fails with:
Error reading JToken from JsonReader. Path '', line 0, position 0.
when steps.release.outputs.pr is empty (for example, when release-please creates a release instead of creating or updating a release pull request).

Reproduction Steps

  1. Merge a release pull request into main.
  2. The Release workflow starts.
  3. release-please creates a release. The output steps.release.outputs.pr is empty.
  4. The GitHub Actions runner evaluates the step template expressions and fails at fromJSON(steps.release.outputs.pr).

Expected vs Actual Behavior

Expected: The step does not fail when steps.release.outputs.pr is empty.
Actual: The GitHub Actions runner template evaluation fails before step execution.

Environment Diagnostics

  • DevOps CLI Version: 0.14.0
  • GitHub Actions runner: ubuntu-24.04

Logs, Traces, or Terminal Output

The template is not valid. .github/workflows/release.yml (Line: 73, Col: 23): Error reading JToken from JsonReader. Path '', line 0, position 0.

Pre-Submission Checklist

  • I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
  • I have checked existing issues and pull requests to ensure this is not a duplicate.

Proposed design

Problem statement

The release workflow step 'Merge the Release Pull Request on an Urgent Fix' fails when release-please creates a release instead of a pull request. The env expression fromJSON(steps.release.outputs.pr).number is evaluated by the runner and throws a template error on empty input, even though the if condition would skip the step. This blocks every release where no pull request is created.

Acceptance criteria

Requirement: Step skips when PR output is empty

The 'Merge the Release Pull Request on an Urgent Fix' step SHALL NOT evaluate fromJSON on an empty steps.release.outputs.pr value.

Scenario: release-please creates a release with no PR

  • WHEN steps.release.outputs.pr is an empty string and steps.release.outputs.releases_created is 'true'
  • THEN the workflow run completes without a template evaluation error on that step

Requirement: Step still merges on urgent fix

When steps.release.outputs.pr is non-empty and the pushed commit is an urgent fix, the step SHALL merge the release pull request with gh pr merge --auto --squash.

Scenario: urgent fix with a release PR present

  • WHEN steps.release.outputs.pr contains valid JSON with a number field and the pushed commit carries the release-now label
  • THEN gh pr merge is called with the correct PR number and --auto --squash flags

Requirement: No new dependencies

The fix SHALL NOT add any new package, action, or runner dependency.

Scenario: review the changed file

  • WHEN the diff of .github/workflows/release.yml is inspected
  • THEN no new uses: line, no new apt-get install, and no new pip or uv package appears

Existing Tool Considered

GitHub Actions expression language provides fromJson() for parsing JSON in step env blocks, but it throws on empty or null input. The runner image (ubuntu-24.04) ships jq, which parses JSON in a shell script and returns an empty string on empty input, letting the script guard the result. No new dependency is added; the fix moves one expression from the env block into the run script and uses jq.

Key questions

  • Why does the env expression fail even though the if condition checks for empty pr?: The runner evaluates all template expressions in a step definition (including env) before or concurrently with the if check. fromJSON('') throws a template error at that point, so the step never reaches the if evaluation. Moving the parse into the run script avoids this because the run script only executes after the if passes. [sources: .github/workflows/release.yml:73]
  • Where should the JSON parsing of steps.release.outputs.pr happen?: In the run script, using jq. The env block passes the raw JSON string; the script checks for empty input and then extracts .number with jq. This keeps the expression safe because an empty string in env is a valid value, and jq handles the parse in a context where the script can guard it. (best practice) [sources: .github/workflows/release.yml:67, .github/workflows/release.yml:73]
    • Rejected: Keep fromJSON in env, add a null-coalescing guard in the expression. GitHub Actions expressions have no ternary or null-coalesce operator that prevents fromJSON from throwing on empty input. The expression language cannot express 'if empty then skip else parse'.
    • Chosen: Move parsing into the run script with jq. jq is pre-installed on ubuntu-24.04 runners. The script can check for empty input before calling jq, and the env block only carries a plain string, which is always a valid template value.
    • Rejected: Remove the step and rely on the if condition alone. The if condition is correct but does not prevent the env evaluation error. Removing the step loses the urgent-fix auto-merge feature delivered in feat(release): the release pull request merges itself after its checks when an urgent fix lands #1966.
  • Does the fix change the behavior of the urgent-fix auto-merge path?: No. The run script already contains the full logic: find the merged PR for the pushed SHA, check for urgent labels, and call gh pr merge. The only change is how RELEASE_PR is derived: from jq in the script instead of fromJSON in the env block. The script logic is unchanged. [sources: .github/workflows/release.yml:75]
  • Is there a dependency on another issue before this fix can be delivered?: No. The fix is a self-contained change to one step in .github/workflows/release.yml. Issue feat(release): the release pull request merges itself after its checks when an urgent fix lands #1966 delivered the urgent-fix feature; this issue fixes a defect in that step. No other issue must be done first. [sources: .github/workflows/release.yml:67]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    status/new
    value/high
    effort/low
    on Oct 29, 2026
  2. dan-petty commented on Oct 29, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/bug. A workflow step crashes when release-please output is empty; this is a defect fix.
    • Priority: P1-High. The failure blocks every release where release-please creates a release instead of a PR. The failed run 40812475380 does not set P0: the author has no write access, and no caller attached it as evidence. A person can set P0 with the label priority/p0-critical.
    • Value: High. Releases cannot ship until the step handles the empty PR output case.
    • Effort: Low. The fix is a guard or conditional around the fromJSON call in one workflow step.
    • Related: feat(release): the release pull request merges itself after its checks when an urgent fix lands #1966, which asks for a different change. Both touch the release workflow auto-merge step; #1966 delivered the feature, this candidate reports a defect in that step.
  3. added
    priority/p1-high
    on Oct 29, 2026
  4. added a commit that references this issue on Oct 29, 2026
    262244d
  5. added
    status/ready
    and removed
    status/new
    on Oct 29, 2026
  6. devops-cli-service commented on Oct 29, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 38a0a44 (see proposed design in issue body).

  7. removed
    status/ready
    on Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p1-highsource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions