Skip to content

CI: stop grep -c || echo 0 producing a two-line count - #10232

Merged
danielhanchen merged 1 commit into
mainfrom
ci-grep-count-fallback
Sep 3, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
ci-grep-count-fallback

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

grep -c prints 0 and exits 1 when nothing matches, so $(grep -c ... || echo 0) appends a second line and the variable holds 0\n0. Two places in the workflows do that.

studio-frontend-ci.yml

JS=$(ls dist/assets/index-*.js | head -1)
HITS=$(grep -c 'unstable_Provider:' "$JS" || echo 0)
...
if [ "$HITS" -gt 3 ]; then

The bundle has zero hits today, so every run of Frontend build + bundle sanity logs

main bundle: dist/assets/index-Dn5EVPb7.js
unstable_Provider: hits=0
0 (assistant-ui internals contribute up to 3)
/home/runner/work/_temp/....sh: line 6: [: 0
0: integer expression expected

set -e does not catch it because the [ is a condition, so the step stays green while printing a shell error and a mangled diagnostic. Visible on any recent run, for example https://github.com/unslothai/unsloth/actions/runs/33731460431.

The guard itself is not dead in the direction that matters: with real matches grep -c exits 0, || echo 0 never runs, and the comparison fires correctly. I checked that with a 4-match fixture.

What the noise was hiding is the line above it. ls dist/assets/index-*.js | head -1 takes its exit status from head, so a missed glob leaves $JS empty and set -e never sees it. grep -c PAT "" then exits 2 printing nothing, || echo 0 yields a clean single-line 0, and the step passes green on a bundle nobody looked at. That is a failure-open in a regression gate, and it is the reason to touch this at all.

So this now checks the bundle exists before scanning it, and uses || true with a ${HITS:-0} default, which also covers the grep exit-2 case where nothing is printed.

Verified all three paths in bash:

case before after
zero matches [: 0\n0: integer expression expected, step green hits=0, pass, no error
four matches fires correctly fires correctly
no index-*.js passes green without scanning ::error::no dist/assets/index-*.js to scan, exit 1

notebooks-ci.yml

The seed-pin fallback counter has the same shape. That value is only interpolated into ::error::/::warning:: annotations, never into a numeric test, so the cost is a two-line annotation that GitHub truncates after the first line. Same one-line fix while it is open.

Scope

I swept the tree for the pattern: those are the only two. .github/workflows/cache-janitor.yml:187 and the tests/sh/ suite already use || true, and the remaining || echo 0 sites are non-counting commands whose failure prints nothing, so the fallback is sound there.

Nothing here changes what any check passes or fails on today.

Unrelated, while I was in this job

Frontend build + bundle sanity was red on main and 15 open PRs for over the startup budget: transfer 1568.0 KB > 1562.5 KB. #10054 has since raised BUDGET.transferBytes to 1,620,000, so that is green again and this PR does not touch it.

Worth knowing where those bytes went, though. assets/api-provider-logo-*.js is 303.2 KB raw / 80.8 KB transfer on the eager startup path and is 96% node-forge: x509.js 56.9 KB, tls.js 55.8 KB, util.js 35.7 KB, jsbn.js 31.1 KB, rsa.js 30.2 KB, ed25519.js 23.1 KB. It arrives from two static imports, studio/frontend/src/features/chat/api/providers-api.ts:4 and studio/frontend/src/features/chat/utils/chat-attachment-events.ts:11. Both call sites are already async: one encrypts a provider API key when you save one in Settings, the other is a fallback SHA-256 for when crypto.subtle is unavailable. node-forge's default export is a non-tree-shakeable barrel, so one md.sha256.create() pulls the whole X.509/TLS/PKCS library onto the boot path.

Making both dynamic measures at 1495.9 KB transfer / 4984.4 KB raw against 1568.0 / 5259.1, so 72.1 KB of transfer back, no change in chunk count, and the eager path returns to roughly what it measured when the budget was first calibrated at 17363f8a2. That is more than the 57.5 KB the ceiling was just raised by. I have left it out of this PR since it is a frontend change and not a CI one, but it is there if someone wants the headroom back rather than the raised ceiling.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-03T09:27:24.966701Z b06ef7b Manual request
🔒 Security Review ✅ Completed 2026-09-03T09:28:45.788690Z b06ef7b Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: b06ef7be54

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: b06ef7be54

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@danielhanchen
danielhanchen merged commit 568b736 into main Sep 3, 2026
15 checks passed
@danielhanchen
danielhanchen deleted the ci-grep-count-fallback branch September 3, 2026 09:57
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.

1 participant