From b7e8c183408e42e42ae9d6d641d507257526d08e Mon Sep 17 00:00:00 2001 From: Fahima Mokhtari Date: Mon, 27 Jul 2026 18:59:14 +0100 Subject: [PATCH 1/2] fix(tests): stop snippet tests failing when two runs overlap 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. --- .github/workflows/test-snippets.yml | 9 +++++++++ tests/conftest.py | 8 ++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-snippets.yml b/.github/workflows/test-snippets.yml index 3ae3ffb..b5f0216 100644 --- a/.github/workflows/test-snippets.yml +++ b/.github/workflows/test-snippets.yml @@ -8,6 +8,15 @@ on: - '*.mdx' - 'tests/**' +# These tests create shared, named resources on one Eden AI account (custom +# tokens, uploaded files), so two runs of the same ref must not overlap. +# update-dates.yml pushes a dateModified bump to every .mdx PR, which starts a +# second run seconds after the first — superseding the earlier run avoids the +# collision instead of losing a coin flip. +concurrency: + group: test-snippets-${{ github.ref }} + cancel-in-progress: true + jobs: execute: name: Execution Tests diff --git a/tests/conftest.py b/tests/conftest.py index 6839791..6d9514f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -79,8 +79,12 @@ def pytest_sessionstart(session: pytest.Session) -> None: try: create_custom_token(**token_spec) except requests.HTTPError as exc: - # token may already exist - if not exc.response or exc.response.status_code != 400: + # Token may already exist — another run on the same account can + # create it first. Test `is None` explicitly: Response.__bool__ + # returns self.ok, so a 400 response is falsy and `not + # exc.response` was short-circuiting to True, re-raising the one + # case this handler exists to swallow. + if exc.response is None or exc.response.status_code != 400: raise path = _shared_state_path(session.config) From 020882d84c768b9d65e31e2445027554a0fcb851 Mon Sep 17 00:00:00 2001 From: Fahima Mokhtari Date: Mon, 27 Jul 2026 19:03:33 +0100 Subject: [PATCH 2/2] fix(tests): queue overlapping runs instead of cancelling them MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .github/workflows/test-snippets.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-snippets.yml b/.github/workflows/test-snippets.yml index b5f0216..873c456 100644 --- a/.github/workflows/test-snippets.yml +++ b/.github/workflows/test-snippets.yml @@ -11,11 +11,17 @@ on: # These tests create shared, named resources on one Eden AI account (custom # tokens, uploaded files), so two runs of the same ref must not overlap. # update-dates.yml pushes a dateModified bump to every .mdx PR, which starts a -# second run seconds after the first — superseding the earlier run avoids the -# collision instead of losing a coin flip. +# second run seconds after the first, so serialise them per ref. +# +# Deliberately NOT cancel-in-progress: cleanup happens in pytest_sessionfinish, +# so cancelling a started run orphans the tokens and uploaded file it created. +# The next run then snapshots those as pre-existing and never deletes them, +# leaking a little account state on every .mdx PR. Queuing costs one extra +# minute of CI and always runs cleanup. (A still-pending run carries no +# resources, so GitHub replacing it is harmless.) concurrency: group: test-snippets-${{ github.ref }} - cancel-in-progress: true + cancel-in-progress: false jobs: execute: