Skip to content

sendsketch/TaxServer returns HTTP 400 (NumberFormatException) for single-k sketch servers (e.g. k=31) #23

Description

@rec3141

Symptom

A locally-hosted TaxServer (the sendsketch.sh server) returns HTTP 400 for every query when the sketch uses a single k-mer length (e.g. a custom k=31 sketch DB):

<h1>400 Bad Request</h1>NumberFormatException thrown

With assertions enabled (-ea) the server thread instead crashes silently. This makes it impossible to run a local sketch server (GTDB, RefSeq, custom genomes, etc.) built with a single k.

Queries against JGI's public servers are unaffected, because those use the default dual-k (k=32,24), which takes a different parse branch.

Root cause

current/sketch/SketchTool.java, method loadSketchesFromString() (the path that parses the sketch a client POSTs). The single-value branch of the K: header parser passes the full field string s ("K:31") to Integer.parseInt instead of the value substring sub ("31"):

}else if(s.startsWith("K:")){//Kmer length
    if(sub.indexOf(',')>=0){            // dual-k: "K:32,24" -> OK
        ...
    }else{
        k_sketch=Integer.parseInt(s);   // single-k: "K:31" -> NumberFormatException
        k2_sketch=0;
    }
}

The comma branch and every other field parser in the same block (H:, BC:, GS:, GK:, …) already use sub; only this single-k branch uses s. The two file-reading parsers (loadSketchesFromSketchFile/...File2) are correct — only loadSketchesFromString is affected.

Reproduction (current master, v39.91)

query sketch result
single k=31 (K:31) HTTP 400 / NumberFormatException
default dual-k (K:32,24) works
  1. sketch.sh in=ref.fa out=db_k31.sketch k=31 mode=sequence
  2. taxserver.sh tree=tree.taxtree.gz port=3068 k=31 index db_k31.sketch
  3. sendsketch.sh in=query.fa address=http://localhost:3068/sketch k=31 → 400

Also present in 39.52.

Fix / workaround

One-line fix submitted as #22:

-										k_sketch=Integer.parseInt(s);
+										k_sketch=Integer.parseInt(sub);

Until that's released, anyone hitting this can patch current/sketch/SketchTool.java in their install (the single-k branch in loadSketchesFromString), recompile that one class against their bbtools.jar, and restart the server — or build their sketches with the default k=32,24 instead of a single k.


🤖 Generated with Claude Code — model: Claude Opus 4.8 (1M context) (claude-opus-4-8[1m])

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions