Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Comments

Close side panel

Respect --exit-status with --log and --log-failed in run view#12679

Merged
williammartin merged 1 commit intotrunkcli/cli:trunkfrom
wm-run-view-exit-status-not-respectedcli/cli:wm-run-view-exit-status-not-respectedCopy head branch name to clipboard
Feb 13, 2026
Merged

Respect --exit-status with --log and --log-failed in run view#12679
williammartin merged 1 commit intotrunkcli/cli:trunkfrom
wm-run-view-exit-status-not-respectedcli/cli:wm-run-view-exit-status-not-respectedCopy head branch name to clipboard

Conversation

@williammartin
Copy link
Member

@williammartin williammartin commented Feb 13, 2026

Description

Fixes #12674

When --exit-status was passed alongside --log or --log-failed, the command always exited 0 because the log display code path returned early without checking the run's conclusion.

This adds the exit-status check after displaying logs, matching the behavior of the non-log code paths.

Acceptance Criteria

Given I have a failing job
When I run gh run view with --exit-status and either --log or --log-failed
Then the exit status of gh is non-zero

Before, with no log flag

➜ GH_PAGER=cat gh run view --repo cli/cli --exit-status 21973995883 || echo $?


X trunk Bump Go · 21973995883
Triggered via schedule about 11 hours ago

JOBS
X bump-go in 13s (ID 63481482065)
  ✓ Set up job
  ✓ Checkout repository
  ✓ Set up Go
  X Bump Go version
  - Post Set up Go
  ✓ Post Checkout repository
  ✓ Complete job

ANNOTATIONS
X Process completed with exit code 1.
bump-go: .github#15


To see what failed, try: gh run view 21973995883 --log-failed
View this run on GitHub: https://github.com/cli/cli/actions/runs/21973995883

➜  echo $?
1

Before, with log flag

➜  wm-run-view-exit-status-not-respected git:(wm-run-view-exit-status-not-respected) GH_PAGER=cat gh run view --repo cli/cli --log-failed --exit-status 21973995883

bump-go	UNKNOWN STEP	2026-02-13T03:53:41.0131892Z Current runner version: '2.331.0'
bump-go	UNKNOWN STEP	2026-02-13T03:53:41.0154343Z ##[group]Runner Image Provisioner
bump-go	UNKNOWN STEP	2026-02-13T03:53:41.0155291Z Hosted Compute Agent
...

➜ echo $?
0

After, with log flag

➜  GH_PAGER=cat ./bin/gh run view --repo cli/cli --log-failed --exit-status 21973995883

bump-go	UNKNOWN STEP	2026-02-13T03:53:41.0131892Z Current runner version: '2.331.0'
bump-go	UNKNOWN STEP	2026-02-13T03:53:41.0154343Z ##[group]Runner Image Provisioner
bump-go	UNKNOWN STEP	2026-02-13T03:53:41.0155291Z Hosted Compute Agent
...

➜ echo $?
1

Reviewer Notes

I have not extended this to --json flags, which feels like a much bigger conceptual lift.

@williammartin williammartin force-pushed the wm-run-view-exit-status-not-respected branch from 3f51da0 to 2496468 Compare February 13, 2026 15:04
@williammartin williammartin marked this pull request as ready for review February 13, 2026 15:04
@williammartin williammartin requested a review from a team as a code owner February 13, 2026 15:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where the --exit-status flag was not respected when used with --log or --log-failed flags in the gh run view command. The command would always exit with status code 0 even for failed runs when displaying logs, whereas it should exit with a non-zero status for failed runs when --exit-status is specified.

Changes:

  • Modified the log display code path to check opts.ExitStatus and return cmdutil.SilentError for failed runs after displaying logs
  • Added two test cases to verify that exit status is now properly respected with both --log-failed and --log flags

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
pkg/cmd/run/view/view.go Added exit status check after displaying log segments to match non-log code path behavior
pkg/cmd/run/view/view_test.go Added test cases verifying exit status is respected with --log-failed and --log flags for failed runs

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@BagToad BagToad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@BagToad BagToad changed the title Respect --exit-status with --log and --log-failed in run view Respect --exit-status with --log and --log-failed in run view Feb 13, 2026
@williammartin williammartin merged commit 4e76bb0 into trunk Feb 13, 2026
18 checks passed
@williammartin williammartin deleted the wm-run-view-exit-status-not-respected branch February 13, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gh run view: "--exit-status" not respected when passed with other flags

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.