Skip to content

fix: Coerce node and edge types before syncing updates - #76

Merged
philippjfr merged 2 commits into
mainfrom
fix/node-types-update-serialization
Sep 28, 2026
Merged

philippjfr merged 2 commits into
mainfrom
fix/node-types-update-serialization

Conversation

@philippjfr

Copy link
Copy Markdown
Contributor

Description

I fixed a server-side serialization error when node_types or edge_types are assigned after construction. The constructor converts NodeType and EdgeType descriptors to JSON dicts, but on a later update Panel synced the raw value to the frontend before the _normalize_specs watcher replaced it, so a descriptor's schema class reached bokeh and the patch failed with SerializationError: can't serialize <class 'param.parameterized.ParameterizedMetaclass'>. panel-flowdash hits this whenever lazily loaded components rebuild the canvas's node types.

  • _process_param_change now coerces node_types and edge_types with _coerce_spec_map, so only JSON descriptors are synced regardless of watcher order.
  • _normalize_specs now accepts multiple events. It watches both parameters in args mode, so flow.param.update(node_types=..., edge_types=...) raised TypeError: _normalize_specs() takes 2 positional arguments but 3 were given.
import panel as pn
import param
import panel_reactflow as pr

pn.extension()


class Config(param.Parameterized):
    x = param.Integer(default=1)


flow = pr.ReactFlow(sizing_mode="stretch_both", min_height=400)
button = pn.widgets.Button(name="Set node types")
button.on_click(lambda _: flow.param.update(node_types={"a": pr.NodeType(type="a", schema=Config)}))

pn.Column(button, flow).servable()

Serve this and click the button. Before, the server logs SerializationError: can't serialize <class 'param.parameterized.ParameterizedMetaclass'>; after, the update is applied without error.

I added test_updated_node_types_reach_model_as_descriptors and test_node_and_edge_types_updated_together, both of which fail on main and pass with this change. The non-UI test suite and pre-commit pass, as do the panel-flowdash unit and UI suites against this branch.

AI Disclosure

Tool & Model: Kilo Code + Claude Opus 5.5
Usage: Traced the serialization error from panel-flowdash, implemented the fix and tests, and drafted this description; I reviewed the diff and ran the listed checks.

  • I have tested all AI-generated content in my PR.
  • I take responsibility for all AI-generated content in my PR.

Checklist

  • Tests added and are passing
  • Added documentation

@philippjfr
philippjfr merged commit 530efb4 into main Sep 28, 2026
17 checks passed
@philippjfr
philippjfr deleted the fix/node-types-update-serialization branch September 28, 2026 15:54
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