fix(tests): stop snippet tests failing when two runs overlap - #84
Conversation
Execution Tests fails intermittently in pytest_sessionstart, before a single
test is collected:
INTERNALERROR> requests.exceptions.HTTPError: 400 Client Error:
Bad Request for url: .../v2/user/custom_token/
Two causes, both fixed here.
1. The 400 handler never worked. `requests.Response.__bool__` returns
`self.ok`, so a 400 response is falsy and `not exc.response` short-circuits
to True, re-raising the "token may already exist" case the handler exists to
swallow. Compare against None explicitly.
2. Two runs of the same ref overlap. update-dates.yml pushes a dateModified
bump to every .mdx PR, starting a second run seconds after the first; both
then race to create the same named custom token on one shared account. Add a
concurrency group so the newer run supersedes the older.
Observed on PR #81 (run on the content commit passed at 17:34:58, run on the
bot's bump commit failed at 17:35:13) and earlier on #78 and #72. Every affected
run went green on a plain re-run with no code change.
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 3 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
cancel-in-progress would abort a run that had already created its custom tokens and uploaded file. Cleanup lives in pytest_sessionfinish, which a cancelled run never reaches, so those resources would be orphaned — and the next run snapshots them as pre-existing and never deletes them, leaking account state on every .mdx PR. Queuing serialises the runs, still removing the overlap, and always runs cleanup.
Why
Execution Testsfails intermittently on.mdxPRs, dying inpytest_sessionstartbefore a single test is collected:It looks like a content failure and isn't one — no test ever runs. Every affected run has gone green on a plain re-run with no code change.
Two causes
1. The 400 handler has never worked.
tests/conftest.pyintends to tolerate a token that already exists:requests.Response.__bool__returnsself.ok, so a 400 response is falsy.not exc.responseshort-circuits toTrueand re-raises the exact case the handler exists to swallow:Fixed by comparing against
Noneexplicitly, which is what the guard meant.2. Two runs of the same ref overlap.
update-dates.ymlpushes adateModifiedbump to every.mdxPR, which starts a second run seconds after the first. Both then race to create the same named custom token on one shared Eden AI account. Fix 1 makes the loser survive; theconcurrencygroup stops the collision happening at all by superseding the older run.The tests create shared named resources (custom tokens, uploaded files) on a single account, so overlapping runs of the same ref are never safe.
Evidence
PR #81, two runs 15 seconds apart:
3028988273130289902401Same signature on #78 (success 13:16:27, fail 13:16:41) and #72 (failed, passed an hour later untouched).
Scope
Test infrastructure only — no documentation content. Independent of #80 and #81, and worth landing first since it stops those two showing spurious red.