Stop three tests failing on every pull request - #164
Conversation
…emote host Three tests fail on every pull request for reasons unrelated to the changes under review, which blocks anything from merging on a green check. Two API tests asked for "the first" Vermont trap image and then asserted that the pipeline returned detections. The helper took that image from an unsorted glob, so which image it got depended on directory order, which differs between a developer checkout and a fresh CI checkout. One of the three Vermont images is an empty frame where nothing clears the detector's 0.80 score threshold, and CI consistently picked it, so the pipeline correctly returned zero detections and the assertions failed. The helper now sorts, and both tests name the image they need. The source image URL test fetched a thumbnail from a third-party host that now rejects arbitrary thumbnail widths with an HTTP 400. It now serves the image from the local test HTTP server the repository already uses elsewhere, which exercises the same download path without depending on the public internet. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HcXFHJRXMrsHPX7xz9ZifF
|
Warning Review limit reached
Next review available in: 58 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. 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: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
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. Comment |
Summary
Three tests have been failing on every pull request regardless of what the pull request changes, so nothing can merge on a green check. This makes those three tests pass again by removing the two things that made them unreliable: one test depended on a website that changed its behaviour, and two others depended on the order files happen to come back from the filesystem. No application code changes — the fixes are entirely in the tests and their helpers.
The failures were not caused by any of the open pull requests.
mainitself is red: the last time the test workflow ran onmainwas 2026-04-14, and everything since has been Dependabot runs, so the suite has been broken for months without anyone noticing.Two of the three failures turned out not to be network problems at all. The two API tests asked for "the first" trap image and then checked that the ML pipeline found insects in it. The helper picked that image from an unsorted directory listing, so which image a test got depended on arbitrary filesystem ordering, which differs between a developer's checkout and a fresh CI checkout. One of the three Vermont sample images is an empty frame with nothing for the detector to find, and CI kept picking exactly that one. The pipeline was behaving correctly and returning no detections; the test simply had nothing to assert on. On a developer machine the ordering usually landed on an image with insects in it, which is why this looked like a CI-only problem.
The third failure is a genuine external dependency: the test downloaded a thumbnail from Wikimedia, which now refuses arbitrary thumbnail widths and returns an HTTP 400 pointing at its allowed-sizes policy.
List of Changes
test_logits_in_classification_responseandtest_config_num_classification_predictionspass an explicit filename via a newIMAGE_WITH_DETECTIONSconstant intrapdata/api/tests/utils.py.get_test_image_urlssorts the glob result, and accepts an optionalfilenamesargument for tests that need specific images. The argument is added last, so existing callers are unaffected.test_urlwrites an image to a temporary directory and serves it throughStaticFileTestServer, which the repository already uses for this purpose. The same download-and-open code path is exercised.Verification
Run against this branch with the GPU disabled, matching the CPU-only CI runners:
IMAGE_WITH_DETECTIONSat the empty frame reproduces the exact CI failure (AssertionError: No detections found in response), confirming the image choice is what these tests turn on rather than something incidental.Notes for reviewers
The detector threshold and the empty Vermont frame are both left as they are. An image with no insects in it is a reasonable thing to keep in the sample set, and the detector returning nothing for it is correct behaviour; the bug was that a test could land on it by accident.
Worth flagging separately: the ML tests still download model weights from a remote object store at test time. That is a real remaining dependency on an external service, but it is fundamental to what those tests do and out of scope here.