zed-industries/zed · error
{} cannot be built from JSON
Error message
{} cannot be built from JSON What it means
Generated by the derive_action macro: the action type was declared with no_json, so its from_json/to_json ActionPayload builders return this error. It fires at runtime when a caller tries to deserialize this action (e.g. replaying serialized keybindings), not at compile time.
Source
Thrown at crates/gpui_macros/src/derive_action.rs:123
if name.contains("::") {
panic!(
"in #[action] attribute: `name = \"{name}\"` must not contain `::`, \
also specify `namespace` instead"
);
}
let full_name = if let Some(namespace) = namespace {
format!("{namespace}::{name}")
} else {
name
};
let is_unit_struct = matches!(&input.data, Data::Struct(data) if data.fields.is_empty());
let build_fn_body = if no_json {
let error_msg = format!("{} cannot be built from JSON", full_name);
quote! { Err(gpui::private::anyhow::anyhow!(#error_msg)) }
} else if is_unit_struct {
quote! { Ok(Box::new(Self)) }
} else {
quote! { Ok(Box::new(gpui::private::serde_json::from_value::<Self>(_value)?)) }
};
let json_schema_fn_body = if no_json || is_unit_struct {
quote! { None }
} else {
quote! { Some(<Self as gpui::private::schemars::JsonSchema>::json_schema(_generator)) }
};
let deprecated_aliases_fn_body = if deprecated_aliases.is_empty() {
quote! { &[] }
} else {
let aliases = deprecated_aliases.iter();
quote! { &[#(#aliases),*] }
};View on GitHub (pinned to f4178619ac)
Solutions
- Avoid serializing/deserializing this action type; keep it dispatch-only
- If JSON round-tripping is needed, remove no_json and implement proper (de)serialization
- Audit generic action-replay paths to skip actions whose type opted out of JSON
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/gpui_macros/src/derive_action.rs:123 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20).
Data as JSON: /api/errors/b503dce33ab9f8ee.
Report an issue: GitHub.