Skip to content

fix(ci): fix mirror SHA detection in e2e-label-help workflow#2236

Open
rhuss wants to merge 1 commit into
NVIDIA:mainfrom
rhuss:fix/e2e-label-help-mirror-sha
Open

fix(ci): fix mirror SHA detection in e2e-label-help workflow#2236
rhuss wants to merge 1 commit into
NVIDIA:mainfrom
rhuss:fix/e2e-label-help-mirror-sha

Conversation

@rhuss

@rhuss rhuss commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fix the e2e-label-help workflow incorrectly displaying raw JSON ({"messa) instead of a SHA when the mirror branch doesn't exist or the API call fails.
  • Switch from the /branches/ API (which can't handle ref names with slashes like pull-request/2223) to /git/ref/heads/ which handles them natively.
  • Add a regex guard to validate that mirror_sha is a 40-char hex string, resetting to empty on any garbage output.

Related Issue

Observed on PR #2223 comment where the hint comment displayed `{"messa` as the mirror SHA.

Root Cause

When the GitHub branches API returns a 404, gh api writes the error JSON to stdout before exiting non-zero. The 2>/dev/null only suppresses stderr, and the || echo "" fallback never fires because stdout already captured the JSON. So mirror_sha gets the full error object, and ${mirror_sha:0:7} truncates it to {"messa.

Changes

  • .github/workflows/e2e-label-help.yml: Switch API endpoint and add SHA validation

Testing

  • Verified locally that gh api repos/NVIDIA/OpenShell/branches/pull-request/2223 --jq '.commit.sha' 2>/dev/null || echo "" returns the raw error JSON (the bug).
  • Verified that gh api repos/NVIDIA/OpenShell/git/ref/heads/pull-request/2223 --jq '.object.sha' 2>/dev/null || true with the regex guard correctly yields an empty string.

Checklist

  • Commit message follows conventional commits
  • DCO sign-off included
  • No unrelated changes

@copy-pr-bot

copy-pr-bot Bot commented Jul 13, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@TaylorMutch TaylorMutch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@rhuss it looks like there's unrelated brainstorm/ files. Please remove those from this PR.

@rhuss rhuss force-pushed the fix/e2e-label-help-mirror-sha branch from 5404974 to 1921ea2 Compare July 13, 2026 20:05
@rhuss

rhuss commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

@TaylorMutch sorry for that, removed now. And I'm trying to prevent this in the future (btw, this was not brainstorming about that fix which is trivial, it was about left over files from previous session. fully my bad, sorry. Wow, what a track record for starting :-])

@TaylorMutch

Copy link
Copy Markdown
Collaborator

/ok to test 1921ea2

@TaylorMutch TaylorMutch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The workflow change itself looks correct, but the current commit message contains Assisted-By: 🤖 Claude Code. The repository contribution instructions explicitly prohibit mentioning Claude or any AI agent in commit messages. Please amend the commit to remove that trailer and force-push the updated commit.

The branches API endpoint cannot handle ref names with slashes (e.g.
pull-request/2223). When the API returns a 404, gh api writes the error
JSON to stdout before exiting non-zero, so the || fallback never fires.
This causes mirror_sha to contain raw JSON like {"message":"Branch not
found",...} and the comment displays `{"messa` as the SHA.

Switch to the git/ref/heads/ endpoint which handles slashes natively,
and add a regex guard to reset mirror_sha to empty when it does not
look like a valid 40-char hex SHA.

Signed-off-by: Roland Huß <rhuss@redhat.com>
@rhuss rhuss force-pushed the fix/e2e-label-help-mirror-sha branch from 1921ea2 to cb1f3e7 Compare July 14, 2026 13:14
@rhuss

rhuss commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

Sorry for the Assisted-By:, that came from an overwrite in my global config. Fixed, won't happen in the future anymore.

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.

2 participants