JuliaPlots / JuliaPlots/PlotlyJS.jl

IJulia cannot serialize SyncPlot display data, causing Invalid Signature and blank output

Open Beginner friendly
#526 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
444
Forks
86
PR merge metrics
No merged PRs in 30d

Description

## Summary

Displaying a `PlotlyJS.SyncPlot` in a recent IJulia notebook produces no plot. The underlying error is:

```text
ArgumentError: Cannot serialize Plot{...} to JSON
```

Because this exception occurs after IJulia starts sending an `execute_result` multipart ZMQ message, the visible server-side error is instead:

```text
ValueError: Invalid Signature: b"error"
```

## Minimal reproduction

```julia
using PlotlyJS
x = 0:0.01:1
y = sin.(x)
plot(x, y, label="y", linewidth=2)
```

The `SyncPlot` itself is constructed successfully, and its WebIO JSON and HTML representations can be generated with `repr`. The failure happens when IJulia serializes the dictionary returned by the PlotlyJS IJulia extension.

## Root cause

`ext/IJuliaExt.jl` currently contains:

```julia
"application/vnd.plotly.v1+json" => JSON.lower(p)
```

For `p::PlotlyJS.SyncPlot`, `JSON.lower(p)` unwraps only one level and returns the internal `PlotlyBase.Plot`. Recent IJulia serializes the complete message with `IJulia.JSONX`, which cannot serialize that `Plot` object.

The full underlying stack trace ends in:

```text
ArgumentError: Cannot serialize Plot{...} to JSON
at IJulia.JSONX.write_json
at IJulia.send_ipython
at IJulia.execute_request
```

## Verified workaround

Changing the Plotly MIME entry to fully lower the underlying plot resolves the failure:

```julia
"application/vnd.plotly.v1+json" => PlotlyJS.JSON.lower(p.plot)
```

With that change, the same reproduction returns an `execute_result` containing:

```text
application/vnd.plotly.v1+json
text/html
text/plain
```

The WebIO-backed HTML representation remains present, and no invalid ZMQ signature is produced.

## Environment

```text
Julia 1.12.7
PlotlyJS 0.18.18
IJulia 1.34.4
WebIO 0.8.21
Jupyter Client 8.10.0
Jupyter Server 2.21.0
macOS arm64
```

I can prepare a PR with the one-line fix and a regression test if this approach is acceptable.

Contributor guide

No contributing guide indexed for this repository

Research direction

Read ext/IJuliaExt.jl and the IJulia display serialization path first. Reproduce the issue with the provided SyncPlot example, then add a regression test for the MIME dictionary; done means the execute_result includes application/vnd.plotly.v1+json, text/html, and text/plain without an Invalid Signature error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, julia
Domain
data-visualization
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
86/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.