test(relayflows): stop the readiness probe dying on "broker is starting" - #1847
Conversation
The muse-unattended-startup case builds its `api()` helper around `await response.json()`, so the body was parsed before any caller looked at the status. The broker answers `Broker is starting, please retry` as plain text while it comes up -- precisely what the readiness probe is waiting to stop seeing -- so the parse threw, the rejection escaped `waitFor`, and the whole case failed on a startup race rather than retrying. The helper now reads the body as text and parses it only if it is JSON, keeping the raw text as the body so an assertion message still shows what came back. `broker-local-only` already survives this by wrapping its probe in try/catch; this fixes the cause instead, so every call site benefits. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe readiness API helper now parses response text as JSON when possible and returns raw text when parsing fails. This prevents plain-text broker startup responses from throwing during readiness probes. ChangesStartup response handling
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The readiness probe can retry while the broker returns its temporary plain-text startup response. The test-only change is ready to merge. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. A rabbit checks the broker at dawn Comment |
Problem
Flows v2 shard 4fails intermittently on unrelated PRs with:The case's
api()helper parsed the body before anyone checked the status:and the readiness probe is built on it:
While the broker starts it answers
Broker is starting, please retryas plain text — exactly the state the probe exists to wait out.response.json()throws on it, and becausewaitFortreats a rejected probe as fatal rather than falsy, the case fails instead of retrying. It is a pure startup race: nothing about the code under test is wrong.Fix
Read the body as text and parse it only when it is JSON, keeping the raw text as
bodyso assertion messages still show what came back.broker-local-onlysurvives the same response only because it wraps its probe intry/catch { return false }; fixing the helper addresses the cause, so every call site in the case benefits rather than one probe.Proof
A local server that answers exactly as the broker does — plain text
503first, JSON200after — run against both helper versions:The old helper reproduces the CI error verbatim; the new one retries and reaches ready.
Scope
Test-only, one file. No product behaviour changes, so there is no changelog entry. Four of the other cases that parse unconditionally talk to their own
/observationsfixture, which is always JSON;broker-local-onlyis the fifth and is already guarded.🤖 Generated with Claude Code
Note
Low Risk
Test harness-only change; no production code or runtime behavior affected.
Overview
Fixes a flaky muse-unattended-startup relayflow where the broker readiness
waitForcould fail during startup instead of retrying.The case’s
api()helper no longer callsresponse.json()unconditionally. It reads the body as text, parses JSON when possible, and otherwise keeps the plain-text body (e.g.Broker is starting, please retry). The probe only checks HTTP status, so non-JSON startup responses no longer throw and abortwaitFor.Test-only change in
tests/relayflows/cases/muse-unattended-startup/run.mjs; no product behavior changes.Reviewed by Cursor Bugbot for commit ecc495f. Bugbot is set up for automated code reviews on this repo. Configure here.