Skip to content

Fix flaky GenbankProxySequenceReaderTest (NCBI 429s) - #1170

Merged
josemduarte merged 2 commits into
biojava:masterfrom
josemduarte:jd/genbank-proxy-429
Dec 4, 2026
Merged

josemduarte merged 2 commits into
biojava:masterfrom
josemduarte:jd/genbank-proxy-429

Conversation

@josemduarte

Copy link
Copy Markdown
Contributor

GenbankProxySequenceReaderTest regularly fails PR builds with HTTP 429 from NCBI (e.g. the Windows/JDK 17 job on #1169).

The local .gb copies already avoid fetching the protein records, but when a record has a coded_by qualifier the ProteinSequence constructor also fetches the parent nucleotide sequence from NCBI efetch, uncached. The 5 parallel PR matrix jobs, often on shared runner IPs, exceed NCBI's 3 requests/s limit for clients without an API key.

Changes

  1. ProteinSequence no longer throws when the parent fetch fails. On an IOException the old code passed null to new DNASequence(...), so a 429 made the protein impossible to build (NPE), which is why both tests failed. Now the failure is logged and the protein is built without a parent. A join location where any part fails also yields no parent, rather than a silently shortened sequence. The fetch goes through a package-private seam so this is unit-tested offline (ProteinSequenceTest.parentFetchFailureLeavesNoParent, which reproduced the CI stack trace before the fix).
  2. The parent-fetch test moves to biojava-integrationtest as GenbankProxyParentSequenceTest, which runs nightly in a single job. It covers the 4 records with a coded_by, uses a per-test temp dir, and on a failed fetch rebuilds the protein after 2, 5 and 10 s pauses before failing (the 2026-11-30 nightly got a 429 on NC_000932.1 from a single job).

testFeatures stays in core. It still triggers the parent fetch, but a 429 there now only logs an error.

Testing

  • biojava-core: 532 tests, 0 failures.
  • GenbankProxyParentSequenceTest passes against NCBI. No 429 occurred in that run, so the retry path itself was not exercised.

🤖 Generated with Claude Code

josemduarte and others added 2 commits December 3, 2026 22:09
When a record has a coded_by qualifier, the ProteinSequence constructor
fetches the parent nucleotide sequence from NCBI efetch. If that fetch
failed (e.g. HTTP 429), getSequence returned null and the constructor
passed it to new DNASequence(...), throwing a NullPointerException, so the
protein could not be built at all. This is what makes
GenbankProxySequenceReaderTest flaky in CI.

Now a failed fetch is logged and the protein is built without a parent
sequence. A join location where any part fails to fetch also yields no
parent, instead of a silently shortened concatenation.

The NCBI fetch goes through a package-private ParentSequenceFetcher seam
so the failure can be tested offline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GenbankProxySequenceReaderTest.testProteinSequenceFactoring checks that
the coded_by parent DNA sequence is fetched from NCBI efetch. The local
.gb copies only cover the protein records, so every PR build job made
these NCBI requests, and the parallel matrix jobs regularly got HTTP 429.

It now lives in biojava-integrationtest as GenbankProxyParentSequenceTest,
which runs nightly in a single job, limited to the four records that have
a coded_by qualifier and using a per-test temp dir for the cached records.
It also asserts the parent unconditionally for those records, where the
old test silently skipped records without a single CDS.

Even a single nightly job gets an occasional 429 (other traffic from the
same runner IP), so when the parent is missing the test rebuilds the
protein after a pause of 2, 5 and then 10 s before failing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@josemduarte
josemduarte merged commit 63badef into biojava:master Dec 4, 2026
5 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