Repository navigation
fix(server): validate decoded specs at /view, /h and /share - #114
Merged
Merged
Conversation
This was referenced Sep 29, 2026
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.
Closes #99.
Change
/view,/h/{n}and/sharevalidate a decoded spec where it enters the server (_validated_dashboardinserver.py): they build every trace withbuild_trace_from_spec. An invalid spec returns 400Invalid spec: ....bar_mode, at most one heatmap) are a model validator onFigureSpec(spec.py). The builder, a decoded spec and every/dashboard/updaterequest run them, so the server needs no import fromfigure.py._validate_bar_modesand_validate_heatmap_countinfigure.pyare deleted.bar_modeonly fromdisplay. No producer has writtenparams.bar_modesince the first release./viewand/h/{n}render the specs that the rebuilt traces emit. So the page sees normalized values, for example the Plotly spelling of a lowercasecolor_scalefrom an older share URL./sharevalidates and encodes the spec as sent._plotly_heatmap_color_scale,_plotly_heatmap_color_range,_check_plotly_heatmap_color_normand_HEATMAP_STYLE_INVARIANT_ERRORare deleted, with the adapter's import from the trace helpers. The ECharts adapter keeps its checks.CorrHeatmap.from_trace_specrejects acolor_normkey, because the adapter check that rejected it is gone.Architecture.md: the heatmap styling contract and the request flow.Impact
color_rangeorcolor_normgave HTTP 500 at/view, and/sharereturned a URL that failed later. Both now return 400 with the message of the trace.bar_modes now returns 400 at/viewand/share, and 422 at/dashboard/update. Before,/dashboard/updateaccepted it."viridis"renders viridis.TraceSpecwithout required params (for examplen_points) now gets 400 at/view. Before, the page rendered and its first/dashboard/updatefailed with 500./dashboard/updatestill returns 500 for an invalid trace, becausebuild_trace_from_specruns outside atrythere.Tests
TestDecodedSpecValidation(tests/test_integration.py): an invalidcolor_range("nope",[5, 1]),color_norm="sqrt", a log range from 0 onhistogram2dand ongeo_histogram2d, and acorr_heatmapwithcolor_norm, each at/viewand/share. Also two heatmaps at both routes and at/dashboard/update, and an old"viridis"spec rendering"Viridis". All 9 fail on the parent branch.TestTraceSpecRoundTrip(tests/test_spec.py): rebuilding each trace from its builder spec gives the sameTraceSpec, for every registered trace type.main:pytest tests: 2289 passed, 1 skipped.pytest -m browser tests: 317 passed, 12 skipped.