Skip to content

Stored "nan"/"inf" values are missing numbers: fix Explore's Code 70 error, one numeric read for every query - #60

Merged
alisman merged 1 commit into
masterfrom
session/page
Oct 23, 2026
Merged

alisman merged 1 commit into
masterfrom
session/page

Conversation

@alisman

@alisman alisman commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Explore failed on the internal portal with ClickHouse error … Code: 70 … Unexpected inf or nan to integer conversion. This fixes it, and the same unguarded read everywhere else.

Reproduction

Some studies record a missing number as the text "nan", "NaN" or "inf". The public warehouse has them too:

Study Values
prostate_pcbm_swiss_2019 PSA in 160 patients; CGA, SYP, Gleason
hcc_meric_2021 survival months, age
pancan_pdx_uthsa_2023 telomere measures
  • Before: POST /api/explore {"study":"prostate_pcbm_swiss_2019"} failed with the Code 70 error, and so did Explore for any selection containing such a study.
  • After: it loads, and no numeric chart has a non-finite minimum, maximum or median.

Cause

toFloat64OrNull("nan") is NaN and toFloat64OrNull("inf") is Infinity. Neither is NULL, so both passed every IS NOT NULL. In Explore's histogram binning a NaN fails both edge tests and reaches toInt32(…), which throws.

The same read was used in 48 other places. There it did not throw: it gave a quiet wrong answer, such as a NaN minimum or median, a NaN survival time, or a NaN plot point.

Fix

lib/sql-number.ts's finiteSql() is the one numeric read of a stored value: a finite Float64, or NULL for anything that is not a number, NaN and ±Infinity included. All 49 such reads in lib now use it:

  • Explore's statistics and histograms
  • cohort range clauses
  • plots and survival months
  • oncoprint heatmaps
  • OQL's expression thresholds
  • composition and timeline lab values

The generic-assay summary already guarded with isFinite and keeps its own form. A new unit test fails on any bare toFloat64OrNull in lib outside those two.

Verification

  • Explore on prostate_pcbm_swiss_2019 (the failing case), pooled with prad_tcga, and on hcc_meric_2021 and pancan_pdx_uthsa_2023: no error, no NaN on the page.
  • No gallery example's pinned count moved.
  • GATE_PORT=4139 scripts/gate.sh passes on this branch, which is on current master: 172 checks, 1,437 unit tests, 37 cohort-logic checks.
    • A first run had one save-cohort browser step fail, at a menu read unrelated to this change; the re-run, with no code change, passed it.

Preview

No deploy preview: this repo deploys to Vercel from master. The internal portal needs a build containing this.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TyVfAhLnjshk2kWewGnLum

…meric read for every query

Some studies record a missing number as the text "nan", "NaN" or "inf". On the public warehouse:
prostate_pcbm_swiss_2019 has PSA in 160 patients plus CGA, SYP and Gleason; hcc_meric_2021 has
survival months and age; pancan_pdx_uthsa_2023 has telomere measures. toFloat64OrNull reads
those as NaN or ±Infinity, not NULL, so they passed every "IS NOT NULL". Explore's histogram
binning then failed outright: "Code: 70 … Unexpected inf or nan to integer conversion". This
broke Explore for any selection containing such a study, on the internal instance and here
alike. Elsewhere the same read was a quiet wrong answer: a NaN minimum or median, a NaN survival
time, a NaN plot point.

lib/sql-number.ts's finiteSql() is now THE numeric read of a stored value: a finite Float64, or
NULL for anything that is not a number, NaN and ±Infinity included. All 49 such reads in lib use
it. That covers Explore's statistics and histograms, cohort range clauses, plots, survival months,
oncoprint heatmaps, OQL's expression thresholds, composition and timeline lab values. The
generic-assay summary already guarded with isFinite and keeps its own form. A unit test fails on
any bare toFloat64OrNull in lib outside those two, and the two tests that matched the old SQL text
now build their expectation from finiteSql.

Verified: Explore on prostate_pcbm_swiss_2019 alone (the failing case), pooled with prad_tcga, and
on hcc_meric_2021 and pancan_pdx_uthsa_2023 loads with no error and no non-finite minimum,
maximum or median. No gallery example's pinned count moved. scripts/gate.sh green: 172 checks,
1,437 unit tests, 37 cohort-logic checks. A first run had one save-cohort browser step fail, at a
menu read unrelated to this change; it passed on the re-run with no code change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TyVfAhLnjshk2kWewGnLum
@vercel

vercel Bot commented Oct 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cbiolab-genie Ready Ready Preview Oct 23, 2026 3:03am UTC
cohort-lab Ready Ready Preview Oct 23, 2026 3:03am UTC

Request Review

@alisman
alisman merged commit 2f5e642 into master Oct 23, 2026
8 checks passed

This branch was successfully deployed

1 active deployment
Preview – cohort-lab — d7fa8adf Deployed Oct 23, 2026 by vercel[bot]
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