Skip to content

fix(ci-gate): strip 4-byte UTF-8 from status descriptions before truncating (stacked on #141) - #146

Open
hyperpolymath wants to merge 2 commits into
claude/ci-gate-self-startfrom
claude/intelligent-johnson-i64bfk-pr141
Open

hyperpolymath wants to merge 2 commits into
claude/ci-gate-self-startfrom
claude/intelligent-johnson-i64bfk-pr141

Conversation

@hyperpolymath

@hyperpolymath hyperpolymath commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

Bug

The reusable ci-gate.yml posts commit status CI/gate. GitHub's statuses API rejects any description containing a codepoint above U+FFFF (HTTP 422 "Description doesn't accept 4-byte Unicode"). In this branch the verdict step builds not green: $bad from check-run and workflow-run names (ci-gate.yml line 165 before the fix), and those names carry emoji. The POST fails, the step exits 1, and the failure handler posts CI/gate = failure: a false red.

Audit of every description write in this branch: lines 113, 163, 167, 171 and 186 are static text; line 127/129 is publish(); only line 165 (not green: $bad) carries untrusted names, and it goes through publish().

Fix and chokepoint

publish() is the one verdict write site. It now strips every codepoint above U+FFFF with the regex-free explode | map(select(. <= 65535)) | implode (the same expression as #144) BEFORE cutting to 140 characters (character-based, locale independent; the old bash ${d:0:139} was locale dependent).

The earlier revision of this PR used the equivalent gsub("[\\x{10000}-\\x{10FFFF}]"; ""). It was replaced to align with #144; there is no behaviour change, and both forms were tested equal on jq 1.6, 1.7, 1.7.1, 1.8.0 and 1.8.1.

jq versions verified

tests/ci-gate.sh passes (19 passed, 0 failed) under each of jq 1.6, 1.7, 1.7.1, 1.8.0 and 1.8.1, and under the system jq (1.7).

Test evidence

This branch had no ci-gate test, so tests/ci-gate.sh is new, in the style of the other tests/*.sh, and is wired into code-hygiene-self-test.yml (plus ci-gate.yml in its path filters).

  • It extracts the real publish() from the workflow and runs it against a fake gh that refuses a 4-byte description like the real API: a name with the two emoji, emoji straddling the 140 boundary, a 160-character name, no byte >= 0xF0, at most 140 codepoints, BMP text and state preserved, plain descriptions unchanged, plus a static guard that no description is built from a variable outside publish(), that the BMP_ONLY expression appears exactly once in the workflow, and that no gsub range strip remains.
  • Fail-before: against the unfixed workflow, 9 passed, 9 failed (measured on the earlier revision of this PR).
  • Negative controls: the old truncation keeps the emoji (detector fires) and the fake gh refuses 4-byte text. The control still uses the original pre-fix expression.
  • shellcheck (warning level) and actionlint: no new findings against base on the earlier revision; neither tool was available when this refactor was made, so the refactor itself was not linted beyond bash -n. lock-transitive-closure (23/5), lock-pin-contract, lock-self-source-controls, workflow-lock-scope (needs mikefarah yq) and gate-action-owners fail identically at the unmodified base in this sandbox, so they are not caused by this change.

Supersession

The canonical fix lands on #139's stack. #139 already contains #142's commits, so #142 may be superseded, and this PR on #141's stack is a stopgap with the same intent.

Gate-file change

This changes .github/workflows/ci-gate.yml (and code-hygiene-self-test.yml); an admin may need to apply the gate-change-approved label. Agents do not apply it.

What is NOT proven

  • Not exercised against the live GitHub statuses API; the 4-byte rule is modelled by a fake gh.
  • Signature verification (%G?) could not be confirmed locally (no allowed-signers file in the sandbox).
  • Only codepoints above U+FFFF are handled; other characters the API might reject are not.
  • The new self-test step has not run in GitHub Actions yet.

🤖 Generated with Claude Code

https://claude.ai/code/session_01J4QvDiRggj6apeRQKPpAVR

…cating

"not green: $bad" carries check and workflow names, which hold emoji; the
statuses API rejects a codepoint above U+FFFF (HTTP 422), so the publish failed
and the failure handler posted a false red. publish() is the one verdict write
site: it now strips U+10000..U+10FFFF first, then cuts to 140 characters. Adds
tests/ci-gate.sh (extracts publish(), fake gh refusing 4-byte text) and wires it
into code-hygiene-self-test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J4QvDiRggj6apeRQKPpAVR
@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • CI status descriptions containing certain special characters are now accepted, and lengthy descriptions continue to be shortened to fit the supported limit.

The status publisher removes four-byte UTF-8 characters from verdict descriptions before truncating them. A new shell test checks sanitisation, truncation, and related status values. The self-test workflow runs this test and watches changes to the gate workflow.

Changes: Status description handling

Layer / File(s) Summary
Sanitise and truncate descriptions
.github/workflows/ci-gate.yml
publish() removes four-byte UTF-8 characters from verdict descriptions before applying the 140-character limit.
Test and run the publisher contract
tests/ci-gate.sh, .github/workflows/code-hygiene-self-test.yml
The new test checks the extracted publisher with a fake gh, including emoji handling and truncation. The self-test workflow runs the test and adds the gate workflow to its push and pull-request path filters.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related PRs

Suggested reviewers: claude

Merge Risk: Minimal · up to 83f8c

Status descriptions now drop four-byte characters before truncation, so emoji in check names should no longer cause the statuses API to reject the write and post a false red. A new self-test covers the behavior. No merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: stripping 4-byte UTF-8 (codepoints above U+FFFF) from status descriptions before truncation in the ci-gate workflow. It matches the changeset, which modifies publish()…
Description check Passed The description explains the bug (GitHub statuses API rejects 4-byte Unicode in descriptions), the fix in publish(), the audit of description writes, the new tests/ci-gate.sh, its wiring into code-hyg…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: stripping 4-byte UTF-8 (codepoints above U+FFFF) from status descriptions before truncation in the ci-gate workflow. It matches the changeset, which modifies publish() in ci-gate.yml and adds a test. The title is long (93 characters) and includes a stacking note, but it remains specific and accurate.

Full details: Description check

Explanation

The description explains the bug (GitHub statuses API rejects 4-byte Unicode in descriptions), the fix in publish(), the audit of description writes, the new tests/ci-gate.sh, its wiring into code-hygiene-self-test.yml, jq version verification, and the limits of the evidence. It directly relates to the changeset.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 15355f97-9613-495b-8ee3-4b8017774859
Commits

Reviewing files that changed from the base of the PR and between 4713a2b and 83f8cad.

Files selected for processing: 3

  • .github/workflows/ci-gate.yml
  • .github/workflows/code-hygiene-self-test.yml
  • tests/ci-gate.sh

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Recent review details

Context from checks skipped due to timeout: 2

  • GitHub Check: CodeRabbit
  • GitHub Check: gate-pr / gate
Additional context used

GitHub Check: SonarCloud Code Analysis

tests/ci-gate.sh

[warning] 48-48: Assign this positional parameter to a local variable.

See more on https://sonarcloud.io/project/issues?id=hyperpolymath_cicd-suite&issues=AaHsPok_2ytNFjdcsmyz&open=AaHsPok_2ytNFjdcsmyz&pullRequest=146

[warning] 24-24: Assign this positional parameter to a local variable.

See more on https://sonarcloud.io/project/issues?id=hyperpolymath_cicd-suite&issues=AaHsPok_2ytNFjdcsmyw&open=AaHsPok_2ytNFjdcsmyw&pullRequest=146

[failure] 43-43: Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=hyperpolymath_cicd-suite&issues=AaHsPok_2ytNFjdcsmyx&open=AaHsPok_2ytNFjdcsmyx&pullRequest=146

[failure] 66-66: Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=hyperpolymath_cicd-suite&issues=AaHsPok_2ytNFjdcsmy1&open=AaHsPok_2ytNFjdcsmy1&pullRequest=146

[warning] 48-48: Assign this positional parameter to a local variable.

See more on https://sonarcloud.io/project/issues?id=hyperpolymath_cicd-suite&issues=AaHsPok_2ytNFjdcsmyy&open=AaHsPok_2ytNFjdcsmyy&pullRequest=146

[warning] 23-23: Assign this positional parameter to a local variable.

See more on https://sonarcloud.io/project/issues?id=hyperpolymath_cicd-suite&issues=AaHsPok_2ytNFjdcsmyv&open=AaHsPok_2ytNFjdcsmyv&pullRequest=146

[failure] 66-66: Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=hyperpolymath_cicd-suite&issues=AaHsPok_2ytNFjdcsmy0&open=AaHsPok_2ytNFjdcsmy0&pullRequest=146

Additional comments: 3

.github/workflows/ci-gate.yml: 1

126-130: LGTM!

tests/ci-gate.sh: 1

1-91: LGTM!

.github/workflows/code-hygiene-self-test.yml: 1

38-38: LGTM!

Also applies to: 83-83, 177-181

Replace the gsub("[\\x{10000}-\\x{10FFFF}]"; "") strip with the canonical
expression shipped in #144, explode | map(select(. <= 65535)) | implode. It is
applied before the 140-character cap, exactly as before.

There is no behaviour change: both forms drop every codepoint above U+FFFF, and
they were tested equal on jq 1.6, 1.7, 1.7.1, 1.8.0 and 1.8.1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J4QvDiRggj6apeRQKPpAVR
@sonarqubecloud

Copy link
Copy Markdown

@hyperpolymath
hyperpolymath marked this pull request as ready for review November 18, 2026 01:42
@hyperpolymath
hyperpolymath added this pull request to stack #147 November 18, 2026 01:42
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.

3 participants