Skip to content

fix(tests): stop snippet tests failing when two runs overlap - #84

Merged
FahimaGold merged 2 commits into
mainfrom
fahima/fix-snippet-test-race
Jul 27, 2026
Merged

fix(tests): stop snippet tests failing when two runs overlap#84
FahimaGold merged 2 commits into
mainfrom
fahima/fix-snippet-test-race

Conversation

@FahimaGold

Copy link
Copy Markdown
Contributor

Why

Execution Tests fails intermittently on .mdx PRs, dying in pytest_sessionstart before a single test is collected:

INTERNALERROR> requests.exceptions.HTTPError: 400 Client Error:
Bad Request for url: https://staging-api.edenai.run/v2/user/custom_token/

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.py intends to tolerate a token that already exists:

if not exc.response or exc.response.status_code != 400:
    raise

requests.Response.__bool__ returns self.ok, so a 400 response is falsy. not exc.response short-circuits to True and re-raises the exact case the handler exists to swallow:

Response(400) truthiness: False   ->  "not exc.response" evaluates True

Fixed by comparing against None explicitly, which is what the guard meant.

2. Two runs of the same ref overlap. update-dates.yml pushes a dateModified bump to every .mdx PR, 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; the concurrency group 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:

Run Commit Result Started
30289882731 content commit success 17:34:58
30289902401 bot's date bump fail 17:35:13

Same 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.

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.
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 3 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 842b3bd6-d260-4f72-bf6b-b8ec08024526

📥 Commits

Reviewing files that changed from the base of the PR and between 8841266 and 020882d.

📒 Files selected for processing (2)
  • .github/workflows/test-snippets.yml
  • tests/conftest.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fahima/fix-snippet-test-race

Comment @coderabbitai help to get the list of available commands.

@mintlify

mintlify Bot commented Jul 27, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
edenai 🟢 Ready View Preview Jul 27, 2026, 6:00 PM

💡 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.
@FahimaGold
FahimaGold merged commit 18762b2 into main Jul 27, 2026
4 checks passed
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