Skip to content

guard data viewer histogram computation against hist() failures - #17991

Merged
kevinushey merged 2 commits into
mainfrom
bugfix/dataviewer-histogram-error
Jun 16, 2026
Merged

kevinushey merged 2 commits into
mainfrom
bugfix/dataviewer-histogram-error

Conversation

@kevinushey

@kevinushey kevinushey commented Jun 15, 2026 •

Copy link
Copy Markdown
Collaborator

When opening a data frame in the data viewer, RStudio computes a histogram for each numeric column (via hist() in .rs.describeCols(), SessionDataViewer.R) to power the column sparkline and brushing filter.

There are two related problems, both surfacing as hist.default() raising stop("invalid number of 'breaks'") (and other stop() paths):

  1. No error guard. The histogram branch only wrapped the call in suppressWarnings(), which does not catch errors, so any hist() failure propagated and aborted the entire describe call -- breaking the whole data viewer rather than just the offending column.

  2. Collapsed integer breaks. For whole-number columns spanning a small range we build int_breaks <- seq(min - 0.5, max + 0.5, by = 1) to draw one bar per integer. At very large magnitudes (abs value >= ~2^52, reachable since Title: Data viewer fails with "missing value where TRUE/FALSE needed" on integer columns whose range exceeds .Machine$integer.max #17951 coerces integer columns to double) the unit step and 0.5 offsets fall below the floating-point resolution and the sequence collapses to a single value. hist() then treats that lone break as a scalar bin count -- which errors for large negative values (count < 1) and is meaningless for positive ones.

This wraps the histogram computation in .rs.tryCatch() (matching the sibling factor / character-summary branches: on failure the column's histogram fields are cleared and the error is logged), and drops the integer breaks when they collapse so we fall back to default binning. Includes a regression test for the large-magnitude case.

Reported (without a reproducible example) at https://forum.posit.co/t/new-histograms-in-golden-wattle-data-viewer-break/212784

Fixes #17990.

@kevinushey kevinushey added this to the Blue Plumbago milestone Jun 15, 2026
…gnitudes

Whole-number double columns at very large magnitudes (abs value >= ~2^52)
within a narrow range trip the integer-breaks heuristic, but seq() collapses
to a single value at that floating-point resolution. hist() then treats the
lone break as a scalar bin count, erroring with "invalid number of 'breaks'"
for negative values. Drop the collapsed breaks and fall back to default
binning. Adds a regression test.

Addresses #17990
@kevinushey
kevinushey requested a review from gtritchie June 15, 2026 18:27
@github-actions

Copy link
Copy Markdown

🍎 macOS Desktop E2E · ARM64

❌ 3 test(s) failed

███████████████████░ 99% pass rate

✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
378 3 18 0
📥 Download Playwright report

⬇️ playwright-report.zip — extract and open index.html

Includes screenshots, traces, and step-by-step details for every test. Expires in 15 days.


2 shards · macos-26 ARM64 · commit d0a072f4ca6405ddab87682befb17a29bc3b6921 · Run #37

@github-actions

Copy link
Copy Markdown

🪟 Windows Desktop E2E · Server 2025 x64

✅ All tests passed!

████████████████████ 100% pass rate

✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
379 0 19 3
📥 Download Playwright report

⬇️ playwright-report.zip — extract and open index.html

Includes screenshots, traces, and step-by-step details for every test. Expires in 15 days.


2 shards · Windows Server 2025 x64 · commit d0a072f4ca6405ddab87682befb17a29bc3b6921 · Run #37

@kevinushey
kevinushey merged commit a2ac1ad into main Jun 16, 2026
14 of 15 checks passed
@kevinushey
kevinushey deleted the bugfix/dataviewer-histogram-error branch June 16, 2026 00:26
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.

Data viewer breaks when a numeric column's histogram computation fails

1 participant