Skip to content

Tolerate failed Codex review executions - #3807

Merged
masih merged 2 commits into
mainfrom
masih/fix-the-old-ai-review-slack-pipeline
Jul 24, 2026
Merged

Tolerate failed Codex review executions#3807
masih merged 2 commits into
mainfrom
masih/fix-the-old-ai-review-slack-pipeline

Conversation

@masih

@masih masih commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Codex failures previously terminated the shell before the existing fallback review could be generated and posted to Slack. Handle failed invocations as non-blocking so the workflow publishes its fallback review instead.

Codex failures previously terminated the shell before the existing fallback
review could be generated and posted to Slack. Handle failed invocations as
non-blocking so the workflow publishes its fallback review instead.
@cursor

cursor Bot commented Jul 24, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
CI-only resilience change around Codex CLI exit codes; no application, auth, or data-path changes.

Overview
Codex review failures no longer abort the PR→Slack workflow under set -euo pipefail.

Both Codex paths (embedded diff with read-only sandbox and large-diff URL fetch with danger-full-access) now run inside if ! ...; then blocks. On non-zero exit, the step logs that a fallback review will be published instead of exiting immediately. The large-diff path also dumps codex.log to stderr for debugging.

Downstream behavior is unchanged: if review.md is missing or empty, the workflow still writes _Codex produced no output._ and continues to Slack.

Reviewed by Cursor Bugbot for commit b3f6cfb. Bugbot is set up for automated code reviews on this repo. Configure here.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: da2e54edf7

ℹ️ 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".

Comment on lines +101 to +103
> codex.log 2>&1; then
echo "Codex review failed; publishing fallback review." >&2
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Surface Codex invocation failures in the review

When the Codex command exits non-zero without producing review.md, the workflow now logs the failure only to the Actions log and then uploads the generic _Codex produced no output._ fallback to Slack while the job can still finish green. In that failure scenario, the Slack audience has no visible indication that the automated security review failed, which can make a missing review look like an empty review; write the failure reason into review.md or otherwise make the Slack artifact clearly identify the failed invocation.

Useful? React with 👍 / 👎.

@github-actions

github-actions Bot commented Jul 24, 2026

Copy link
Copy Markdown

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedAug 18, 2026, 5:39 PM

@seidroid seidroid Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The PR correctly makes Codex CLI failures non-blocking by wrapping both codex exec invocations in if ! ...; then guards, which suppresses set -e abort so the existing defensive review.md fallback and Slack-post steps still run. The change is symmetric across both diff-size branches and preserves the env -i secret scrubbing; it is safe to merge.

Findings: 0 blocking | 2 non-blocking | 0 posted inline

Blockers

  • None at the file/PR level.

Non-blocking

  • Cursor's second-opinion review (cursor-review.md) is empty — that pass produced no output. Codex's pass reported "No material issues found," consistent with this review.
  • Nit: the stderr log message "Codex review failed; publishing fallback review." is slightly inaccurate for the embedded-diff path, where there is no distinct fallback review — the code simply falls through to the defensive review.md placeholder ("Codex produced no output."). Cosmetic only.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM — straightforward CI workflow fix.

Extended reasoning...

Overview

This PR modifies only .github/workflows/pr-to-slack-codex.yml, wrapping the two codex ... exec invocations in if ! ...; then ... fi blocks. Previously, under set -euo pipefail, a non-zero exit from the Codex CLI would abort the step immediately, skipping the existing fallback logic that writes _Codex produced no output._ into review.md when it's missing/empty. Now a failed Codex run logs a message to stderr and falls through to that existing fallback path, letting the rest of the job (Slack posting) proceed as originally intended.

Security risks

None. This is CI-only shell control flow; no application code, auth, or data paths are touched. Secret handling (OPENAI_API_KEY, SLACK_BOT_TOKEN) is unchanged — the env scrubbing (env -i ...) and downstream Slack upload logic are identical to before.

Level of scrutiny

Low. This is a small, mechanical, self-contained change to a non-production CI workflow, fixing a clear and narrowly-scoped bug (premature script termination) with a minimal, idiomatic bash fix. The change is easy to reason about by inspection and doesn't introduce any new failure modes beyond what already existed (the pre-existing fallback path is unchanged, just now reachable).

Other factors

No bugs were reported by the bug hunting system, and my own read of the diff confirms the fix is correct: both call sites are updated consistently, and the existing if [ ! -s review.md ] defensive check downstream still applies. Cursor's bot summary also concurs this is low risk.

@seidroid seidroid Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The PR wraps both codex exec invocations in if ! ...; then guards so that under set -euo pipefail a Codex failure no longer aborts the step, letting the existing defensive fallback populate review.md and the Slack-posting steps run. The change is correct and achieves its stated goal; only a minor logging inconsistency is worth noting.

Findings: 0 blocking | 3 non-blocking | 0 posted inline

Blockers

  • None at the file/PR level.

Non-blocking

  • Cursor review file (cursor-review.md) is empty — that second-opinion pass produced no output. Codex review reported no material issues.
  • Logging inconsistency between the two failure branches: the large-diff branch dumps the Codex log (cat codex.log >&2) on failure, but the embedded-diff branch only echoes a message. Consider dumping codex.log in both failure paths so embedded-diff failures are equally diagnosable.
  • The fallback placeholder written to review.md (_Codex produced no output._) does not distinguish a Codex execution failure from Codex running successfully but returning nothing; a distinct message on the failure path would make Slack readers aware the review was not actually performed.

@masih
masih marked this pull request as draft July 24, 2026 16:45
@masih
masih marked this pull request as ready for review July 24, 2026 16:45

@seidroid seidroid Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

A small, correct CI-workflow change that wraps the two codex exec invocations in if ! ...; then so Codex failures no longer abort the step under set -euo pipefail, allowing the fallback/placeholder review and Slack-posting steps to run. Low risk; no blocking issues.

Findings: 0 blocking | 4 non-blocking | 1 posted inline

Blockers

  • None at the file/PR level.

Non-blocking

  • Cursor second-opinion review (cursor-review.md) is empty — that pass produced no output. Codex review reported no material issues.
  • Consider generating an actual fallback review on failure rather than only the _Codex produced no output._ placeholder, if the intent (per the PR description) is to publish a meaningful fallback to Slack.
  • The raw ${{ secrets.OPENAI_API_KEY }} interpolation into the env -i command line is pre-existing (not introduced here), but appears in log-adjacent context; worth confirming CI logs don't echo the expanded command.
  • 1 suggestion(s)/nit(s) flagged inline on specific lines.

< prompt.txt \
> codex.log 2>&1; then
echo "Codex review failed; publishing fallback review." >&2
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[nit] Nit: for symmetry with the large-diff branch (which does cat codex.log >&2 on failure at line 142), consider also dumping codex.log here so an embedded-path failure surfaces its cause in the CI logs.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM — straightforward CI-only resilience fix.

Extended reasoning...

Overview

This PR modifies a single GitHub Actions workflow (.github/workflows/pr-to-slack-codex.yml) that runs an automated Codex AppSec review and posts it to Slack. The change wraps the two codex ... exec invocations (embedded-diff and large-diff fallback paths) in if ! ...; then ... fi blocks so that a non-zero exit from Codex no longer aborts the script under set -euo pipefail. This lets the existing downstream fallback (writing _Codex produced no output._ to review.md when it's empty) run and the Slack post still happen.

Security risks

None. This is CI-only tooling that has no bearing on the sei-chain application, consensus, or state machine — it is correctly labeled non-app-hash-breaking. The workflow does not change permission scopes, secret handling, or sandbox settings (--sandbox read-only / --sandbox danger-full-access usage is unchanged from before this PR).

Level of scrutiny

Low. This is a small, mechanical, well-understood shell idiom (if ! cmd; then ...; fi to tolerate a single command's failure under pipefail) applied symmetrically to both existing Codex invocation sites. The change is self-contained to one file and does not touch any production code path.

Other factors

The bug-hunting system found no issues. A P2 comment from the Codex bot itself notes that Slack won't clearly distinguish "Codex failed" from "Codex found nothing" — this is a minor observability nit for an internal tooling workflow, not a correctness or security bug, so it doesn't warrant blocking approval.

@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.21%. Comparing base (b39a8d2) to head (b3f6cfb).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3807      +/-   ##
==========================================
- Coverage   60.18%   59.21%   -0.97%     
==========================================
  Files        2327     2235      -92     
  Lines      194602   184102   -10500     
==========================================
- Hits       117112   109017    -8095     
+ Misses      66918    65366    -1552     
+ Partials    10572     9719     -853     
Flag Coverage Δ
sei-db 70.41% <ø> (ø)
sei-db-state-db ?

Flags with carried forward coverage won't be shown. Click here to find out more.
see 92 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@masih
masih requested a review from bdchatham July 24, 2026 16:53
@masih
masih enabled auto-merge July 24, 2026 16:54

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM — this is a minimal, self-contained CI workflow fix that does exactly what the description says.

What was reviewed: Both Codex invocation blocks (embedded-diff and large-diff paths) — confirmed each is now wrapped in if ! ...; then so a non-zero Codex exit no longer trips set -euo pipefail and aborts the job before the fallback review.md write. Confirmed downstream fallback ("Codex produced no output.") and Slack upload steps are unchanged. The two open review comments (Codex's P2 about surfacing failure text in the Slack artifact, and the seidroid nit about symmetric cat codex.log) are UX/observability suggestions, not correctness bugs.

Extended reasoning...

Overview

Single-file change to .github/workflows/pr-to-slack-codex.yml, a CI workflow that runs Codex-based AppSec review and posts results to Slack. The change wraps the two codex exec invocations (embedded-diff path and large-diff/URL-fetch path) in if ! ...; then ... fi blocks so a non-zero exit code from Codex is caught and logged instead of terminating the script under set -euo pipefail. This lets the existing fallback logic (writing _Codex produced no output._ to review.md when the file is missing/empty) run and post to Slack as before.

Security risks

None. This is purely CI orchestration code with no application, auth, crypto, or data-path changes. Secrets handling (OPENAI_API_KEY, Slack tokens) is unchanged from before this PR — same scrubbed env -i pattern, same sandbox flags (read-only / danger-full-access) per path.

Level of scrutiny

Low. This is a CI-only resilience fix, mechanical in nature (turning an unguarded command into an if ! guarded one, twice, following the same pattern already used for other defensive checks in this file like if [ ! -s review.md ]). It carries the non-app-hash-breaking label and cannot affect chain consensus, application logic, or security boundaries.

Other factors

Two automated reviewers (chatgpt-codex-connector, seidroid) left minor suggestions — surfacing the failure reason in the Slack artifact, and adding a symmetric cat codex.log >&2 to the first branch. Both are observability nits, not bugs; the workflow behaves correctly and safely either way. No outstanding unaddressed substantive concerns block approval.

@masih
masih added this pull request to the merge queue Jul 24, 2026
Merged via the queue into main with commit cc6d8ea Jul 24, 2026
82 checks passed
@masih
masih deleted the masih/fix-the-old-ai-review-slack-pipeline branch July 24, 2026 17:35
@bdchatham bdchatham added the backport release/v6.6 Backport to release v6.6 label Aug 18, 2026
@bdchatham

Copy link
Copy Markdown
Contributor

/backport

@seidroid

seidroid Bot commented Aug 18, 2026

Copy link
Copy Markdown

Successfully created backport PR for release/v6.6:

bdchatham added a commit that referenced this pull request Aug 19, 2026
Backport of #3807 to `release/v6.6`.

Co-authored-by: Masih H. Derkani <m@derkani.org>
Co-authored-by: FromTheRain <bdchatham@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants