toeverything/AFFiNE · error

Failed to load built-in prompt catalog: {error}

Error message

Failed to load built-in prompt catalog: {error}

What it means

Lazy static initialization of the built-in prompt catalog failed (PromptCatalog::load returned Err on the embedded JSON assets) and the code panics, because the native LLM module cannot operate without its built-in prompts.

Source

Thrown at packages/backend/native/src/llm/prompt_catalog.rs:15

use std::{
  collections::{BTreeMap, BTreeSet, HashMap},
  sync::LazyLock,
};

use llm_adapter::core::prompt_template::{TemplateToken, parse_template};
use napi_derive::napi;
use serde::{Deserialize, Serialize};
use serde_json::{Map, Value};

static PROMPT_PARTIALS_SOURCE: &str = include_str!("assets/partials/common.json");
static PROMPT_SPECS_SOURCE: &str = include_str!("assets/prompts/built-in.json");

static BUILTIN_PROMPT_CATALOG: LazyLock<PromptCatalog> = LazyLock::new(|| {
  PromptCatalog::load().unwrap_or_else(|error| panic!("Failed to load built-in prompt catalog: {error}"))
});

#[napi(string_enum)]
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum PromptBuiltin {
  Date,
  Language,
  Timezone,
  HasDocs,
  HasFiles,
  HasSelected,
  HasCurrentDoc,
}

#[napi(object)]
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct PromptParamSpec {

View on GitHub (pinned to b4c8548c09)

Solutions

  1. Verify the built-in prompt catalog files are installed and readable.
  2. Reinstall or rebuild the native module to restore the catalog.
Defensive patterns

Strategy: fallback

When it happens

Trigger: Panics at first access to the built-in prompt catalog when the embedded prompts/built-in.json or partials/common.json fails to parse or a template inside fails to compile.

Common situations: Indicates corrupted or mismatched embedded prompt assets in the native build. Rebuild the native module so the bundled prompt JSON matches the parser expectations.


AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18). Data as JSON: /api/errors/7a4067a474d2e574. Report an issue: GitHub.