fix(ci): fix mirror SHA detection in e2e-label-help workflow#2236
Conversation
TaylorMutch
left a comment
There was a problem hiding this comment.
@rhuss it looks like there's unrelated brainstorm/ files. Please remove those from this PR.
5404974 to
1921ea2
Compare
|
@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 :-]) |
|
/ok to test 1921ea2 |
TaylorMutch
left a comment
There was a problem hiding this comment.
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>
1921ea2 to
cb1f3e7
Compare
|
Sorry for the |
Summary
e2e-label-helpworkflow incorrectly displaying raw JSON ({"messa) instead of a SHA when the mirror branch doesn't exist or the API call fails./branches/API (which can't handle ref names with slashes likepull-request/2223) to/git/ref/heads/which handles them natively.mirror_shais 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 apiwrites the error JSON to stdout before exiting non-zero. The2>/dev/nullonly suppresses stderr, and the|| echo ""fallback never fires because stdout already captured the JSON. Somirror_shagets 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 validationTesting
gh api repos/NVIDIA/OpenShell/branches/pull-request/2223 --jq '.commit.sha' 2>/dev/null || echo ""returns the raw error JSON (the bug).gh api repos/NVIDIA/OpenShell/git/ref/heads/pull-request/2223 --jq '.object.sha' 2>/dev/null || truewith the regex guard correctly yields an empty string.Checklist