{"record":{"id":"5c2fa5571568c157","repo":"zed-industries/zed","slug":"prompt-not-found","errorCode":null,"errorMessage":"prompt not found","messagePattern":"prompt not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/prompt_store/src/prompt_store.rs","lineNumber":317,"sourceCode":"        }\n\n        txn.commit()?;\n\n        Ok(())\n    }\n\n    pub fn load(&self, id: PromptId, cx: &App) -> Task<Result<String>> {\n        let env = self.env.clone();\n        let bodies = self.bodies;\n        cx.background_spawn(async move {\n            let txn = env.read_txn()?;\n            let mut prompt: String = match bodies.get(&txn, &id)? {\n                Some(body) => body.into(),\n                None => {\n                    if let Some(built_in) = id.as_built_in() {\n                        built_in.default_content().into()\n                    } else {\n                        anyhow::bail!(\"prompt not found\")\n                    }\n                }\n            };\n            LineEnding::normalize(&mut prompt);\n            Ok(prompt)\n        })\n    }\n\n    pub fn all_prompt_metadata(&self) -> Vec<PromptMetadata> {\n        self.metadata_cache.read().metadata.clone()\n    }\n}\n\n/// Deprecated: Legacy V1 prompt ID format, used only for migrating data from old databases. Use `PromptId` instead.\n#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash)]\nstruct PromptIdV1(Uuid);\n\nimpl From<UserPromptId> for PromptIdV1 {","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/prompt_store/src/prompt_store.rs#L299-L335","documentation":"PromptStore::load looks a PromptId up in the on-disk redb bodies store. If there is no row and the id is not a built-in prompt with bundled default content, it bails \"prompt not found\" (crates/prompt_store/src/prompt_store.rs:317).","triggerScenarios":"Loading a PromptId that has no row in the store and no built-in fallback - deleted prompts, ids referenced from stale UI or settings, or a race where the cached prompt list and the store drift apart.","commonSituations":"User deletes a custom prompt while a stale UI entry or keybinding still references it; prompt database reset during migration; typos in configured prompt ids.","solutions":["Check existence first via PromptStore::all_prompt_metadata() before calling load","Recreate the prompt or fix the stale reference pointing at it","If every prompt is suddenly missing, the redb store may have been recreated - re-add prompts and report if it recurs"],"exampleFix":"// before\nlet body = prompt_store.load(id.clone(), cx).await?;\n\n// after\nlet exists = prompt_store\n    .all_prompt_metadata()\n    .iter()\n    .any(|meta| meta.id == id);\nif !exists {\n    return Ok(None);\n}\nlet body = prompt_store.load(id, cx).await?;","handlingStrategy":"validation","validationCode":"let exists = prompt_store\n    .all_prompt_metadata()\n    .iter()\n    .any(|meta| meta.id == id);\nif !exists {\n    return Ok(None);\n}\nlet body = prompt_store.load(id, cx).await?;","typeGuard":"fn prompt_exists(prompt_store: &PromptStore, id: &PromptId) -> bool {\n    prompt_store\n        .all_prompt_metadata()\n        .iter()\n        .any(|meta| &meta.id == id)\n}","tryCatchPattern":"match prompt_store.load(id.clone(), cx).await {\n    Ok(body) => Some(body),\n    Err(e) if e.to_string() == \"prompt not found\" => None, // deleted concurrently\n    Err(e) => { log::error!(\"failed to load prompt: {e:#}\"); None }\n}","preventionTips":["Derive prompt lists from all_prompt_metadata() instead of caching ids","Treat load() failure as a normal missing-record case, not a crash"],"tags":["prompts","storage","redb","lookup"],"backgroundTag":"record-not-found","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}