Fix NumberFormatException in SketchTool.loadSketchesFromString for single-k sketches#22
Open
rec3141 wants to merge 1 commit into
Open
Conversation
…ngle-k sketches The single-k (no comma) branch of the K: header parser passed the full field string `s` (e.g. "K:31") to Integer.parseInt instead of the value substring `sub` (e.g. "31"), throwing NumberFormatException. This made TaxServer return HTTP 400 for every sendsketch query whose sketch uses a single kmer length (e.g. a local k=31 sketch server). The two file-reading parsers and the comma branch already use `sub` correctly; only this branch was affected, so default dual-k (k=32,24) sketches were unaffected.
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.
Fixes #23.
Summary
TaxServer(thesendsketch.shserver) returns HTTP 400 for every query whose sketch uses a single k-mer length (e.g. a localk=31sketch server), due to aNumberFormatExceptioninSketchTool.loadSketchesFromString().Root cause
In
current/sketch/SketchTool.java, theK:(k-mer length) header parser inloadSketchesFromString()has a comma branch (dual-k, e.g.K:32,24) and a single-value branch. The single-value branch parsed the full field strings("K:31") instead of the value substringsub("31"):Every other field parser in the same block (
H:,BC:,GS:,GK:, …) and the comma branch correctly usesub. Only this single-k branch useds. The two file-reading parsers (loadSketchesFromSketchFile/...File2) were already correct — onlyloadSketchesFromString(the path that parses incomingsendsketchPOST data) was affected.Fix
Reproduction & verification (on current
master, v39.91)Built two tiny per-sequence sketch DBs from a 5-contig FASTA, started
TaxServerwith each, and queried viasendsketch.sh:k=31(K:31)K:32,24)So default dual-k sketches were never affected (they take the comma branch) — which is why public default-k servers never hit this — but any single-k custom server (common for self-hosted GTDB/RefSeq sketch DBs built with
k=31) returns 400 on every query. The fix restores single-k servers while leaving the dual-k path unchanged.Environment
master@ v39.91 (also confirmed present in 39.52)🤖 Generated with Claude Code — model: Claude Opus 4.8 (1M context) (
claude-opus-4-8[1m])