{"record":{"id":"7a4067a474d2e574","repo":"toeverything/AFFiNE","slug":"failed-to-load-built-in-prompt-catalog-error","errorCode":null,"errorMessage":"Failed to load built-in prompt catalog: {error}","messagePattern":"Failed to load built-in prompt catalog: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/backend/native/src/llm/prompt_catalog.rs","lineNumber":15,"sourceCode":"use std::{\n  collections::{BTreeMap, BTreeSet, HashMap},\n  sync::LazyLock,\n};\n\nuse llm_adapter::core::prompt_template::{TemplateToken, parse_template};\nuse napi_derive::napi;\nuse serde::{Deserialize, Serialize};\nuse serde_json::{Map, Value};\n\nstatic PROMPT_PARTIALS_SOURCE: &str = include_str!(\"assets/partials/common.json\");\nstatic PROMPT_SPECS_SOURCE: &str = include_str!(\"assets/prompts/built-in.json\");\n\nstatic BUILTIN_PROMPT_CATALOG: LazyLock<PromptCatalog> = LazyLock::new(|| {\n  PromptCatalog::load().unwrap_or_else(|error| panic!(\"Failed to load built-in prompt catalog: {error}\"))\n});\n\n#[napi(string_enum)]\n#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]\n#[serde(rename_all = \"snake_case\")]\npub enum PromptBuiltin {\n  Date,\n  Language,\n  Timezone,\n  HasDocs,\n  HasFiles,\n  HasSelected,\n  HasCurrentDoc,\n}\n\n#[napi(object)]\n#[derive(Debug, Clone, Deserialize, Serialize)]\npub struct PromptParamSpec {","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/backend/native/src/llm/prompt_catalog.rs#L1-L33","documentation":"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.","triggerScenarios":"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.","commonSituations":"Indicates corrupted or mismatched embedded prompt assets in the native build. Rebuild the native module so the bundled prompt JSON matches the parser expectations.","solutions":["Verify the built-in prompt catalog files are installed and readable.","Reinstall or rebuild the native module to restore the catalog."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}