Skip to content

Decoded specs skip trace validation: invalid display values give HTTP 500 at /view, and /share accepts them #99

Closed

Description

@jvdd

Problem

/view, /h/{n} and /share do not validate the traces of a decoded spec.

  • _render_spec_html (flexviz/server.py) decodes the spec and checks the link types. It never builds the traces, so the trace validation in from_trace_spec does not run.
  • The Plotly adapter checks some display fields again while it builds the page: _plotly_heatmap_color_scale and _plotly_heatmap_color_range (and color_norm after PR feat(heatmap): add color_norm with a log option to histogram2d and geo_histogram2d #95). These checks raise ValueError or TypeError in adapter._build_dashboard_html, which runs outside the try block. The result is HTTP 500, not 400.
  • /share runs parse_spec and _check_link_types. Its comment says that it applies the checks of /view, but neither runs the trace validation. So /share returns 200 and a URL that fails later.

Other invalid fields are not caught before the page loads at all. They fail only on the first data request.

Reachability

A hand-edited or imported spec (share URL, flexviz history, Export/Import). Reproduced on main (f0b8e7c) with a histogram2d whose display.color_range is "nope" or [5, 1]:

Request Status
POST /share 200
GET /view (the URL from /share) 500 Internal Server Error

Fix

Validate a decoded spec once, where it enters the server:

  1. In _render_spec_html and /share, build every trace with build_trace_from_spec inside the existing try block, so an invalid spec returns 400 Invalid spec: … with the message of the trace. This costs about 0.1 ms for a dashboard with six traces.
  2. Delete the duplicate checks in the adapter (_plotly_heatmap_color_scale, _plotly_heatmap_color_range, and the color_norm check from PR feat(heatmap): add color_norm with a log option to histogram2d and geo_histogram2d #95). The adapter only reads the values.
  3. CorrHeatmap ignores display.color_norm, so a corr_heatmap with color_norm: "log" passes the trace validation. Make it reject the key. The Plotly adapter from PR feat(heatmap): add color_norm with a log option to histogram2d and geo_histogram2d #95 rejects it today, and step 2 removes that check.

Note: after step 2, the trace validation is the only guard against a log color_range at or below 0. Without a guard, logColorbarTicks(-Infinity, …) in the browser never ends.

Regression tests

At the HTTP level, in tests/test_server.py:

  • GET /view with an invalid color_range returns 400, not 500.
  • POST /share with the same spec returns 400.
  • The same for color_norm="sqrt", a log range from 0, and a corr_heatmap with color_norm="log".

Activity

  1. added
    bug
    on Sep 27, 2026
  2. jvdd commented on Sep 29, 2026

    @jvdd
    ContributorAuthor

    Fixed by #114.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions