zed-industries/zed · error

Keymap schema should serialize

Error message

Keymap schema should serialize

What it means

LazyLock initializer panic: serde_json failed to serialize the generated JSON schema for the keymap settings file. Since the schema types use derive-based serialization, failure indicates the schemars-derived Serialize impl returned an error (or a non-string map key), which for these settings types is considered a programming error — the message asserts serialization is statically guaranteed to succeed.

Source

Thrown at crates/json_schema_store/src/json_schema_store.rs:42

static SNIPPETS_SCHEMA: LazyLock<String> = LazyLock::new(|| {
    serde_json::to_string(&snippet_provider::format::VsSnippetsFile::generate_json_schema())
        .expect("VsSnippetsFile schema should serialize")
});

static JSONC_SCHEMA: LazyLock<String> = LazyLock::new(|| {
    serde_json::to_string(&generate_jsonc_schema()).expect("JSONC schema should serialize")
});

#[cfg(debug_assertions)]
static INSPECTOR_STYLE_SCHEMA: LazyLock<String> = LazyLock::new(|| {
    serde_json::to_string(&generate_inspector_style_schema())
        .expect("Inspector style schema should serialize")
});

static KEYMAP_SCHEMA: LazyLock<String> = LazyLock::new(|| {
    serde_json::to_string(&settings::KeymapFile::generate_json_schema_from_inventory())
        .expect("Keymap schema should serialize")
});

static ACTION_SCHEMA_CACHE: LazyLock<RwLock<HashMap<String, String>>> =
    LazyLock::new(|| RwLock::new(HashMap::default()));

// Runtime cache for dynamic schemas that depend on runtime state:
// - "settings": depends on installed fonts, themes, languages, LSP adapters (extensions can add these)
// - "settings/lsp/*": depends on LSP adapter initialization options
// - "debug_tasks": depends on DAP adapters (extensions can add these)
// Cache is invalidated via notify_schema_changed() when extensions or DAP registry change.
static DYNAMIC_SCHEMA_CACHE: LazyLock<RwLock<HashMap<String, String>>> =
    LazyLock::new(|| RwLock::new(HashMap::default()));

pub fn init(cx: &mut App) {
    cx.set_global(SchemaStore::default());
    project::lsp_store::json_language_server_ext::register_schema_handler(
        handle_schema_request,
        cx,

View on GitHub (pinned to f4178619ac)

Solutions

  1. Reproduce by calling serde_json::to_string on KeymapFile::generate_json_schema() in a test to surface the underlying serde error
  2. Check any custom Serialize/JsonSchema impls on keymap settings types for fallible paths
  3. Fix the type or serializer so serialization is infallible, preserving the invariant
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/json_schema_store/src/json_schema_store.rs:42 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/82580ade11e46494. Report an issue: GitHub.