Repository navigation
Fix flaky GenbankProxySequenceReaderTest (NCBI 429s) - #1170
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GenbankProxySequenceReaderTestregularly fails PR builds with HTTP 429 from NCBI (e.g. the Windows/JDK 17 job on #1169).The local
.gbcopies already avoid fetching the protein records, but when a record has acoded_byqualifier theProteinSequenceconstructor 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
ProteinSequenceno longer throws when the parent fetch fails. On anIOExceptionthe old code passednulltonew 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. Ajoinlocation 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).biojava-integrationtestasGenbankProxyParentSequenceTest, which runs nightly in a single job. It covers the 4 records with acoded_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 onNC_000932.1from a single job).testFeaturesstays in core. It still triggers the parent fetch, but a 429 there now only logs an error.Testing
biojava-core: 532 tests, 0 failures.GenbankProxyParentSequenceTestpasses against NCBI. No 429 occurred in that run, so the retry path itself was not exercised.🤖 Generated with Claude Code