zed-industries/zed · error

prompt not found

Error message

prompt not found

What it means

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).

Source

Thrown at crates/prompt_store/src/prompt_store.rs:317

        }

        txn.commit()?;

        Ok(())
    }

    pub fn load(&self, id: PromptId, cx: &App) -> Task<Result<String>> {
        let env = self.env.clone();
        let bodies = self.bodies;
        cx.background_spawn(async move {
            let txn = env.read_txn()?;
            let mut prompt: String = match bodies.get(&txn, &id)? {
                Some(body) => body.into(),
                None => {
                    if let Some(built_in) = id.as_built_in() {
                        built_in.default_content().into()
                    } else {
                        anyhow::bail!("prompt not found")
                    }
                }
            };
            LineEnding::normalize(&mut prompt);
            Ok(prompt)
        })
    }

    pub fn all_prompt_metadata(&self) -> Vec<PromptMetadata> {
        self.metadata_cache.read().metadata.clone()
    }
}

/// Deprecated: Legacy V1 prompt ID format, used only for migrating data from old databases. Use `PromptId` instead.
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash)]
struct PromptIdV1(Uuid);

impl From<UserPromptId> for PromptIdV1 {

View on GitHub (pinned to f4178619ac)

Solutions

  1. Check existence first via PromptStore::all_prompt_metadata() before calling load
  2. Recreate the prompt or fix the stale reference pointing at it
  3. If every prompt is suddenly missing, the redb store may have been recreated - re-add prompts and report if it recurs

Example fix

// before
let body = prompt_store.load(id.clone(), cx).await?;

// after
let exists = prompt_store
    .all_prompt_metadata()
    .iter()
    .any(|meta| meta.id == id);
if !exists {
    return Ok(None);
}
let body = prompt_store.load(id, cx).await?;
Defensive patterns

Strategy: validation

Validate before calling

let exists = prompt_store
    .all_prompt_metadata()
    .iter()
    .any(|meta| meta.id == id);
if !exists {
    return Ok(None);
}
let body = prompt_store.load(id, cx).await?;

Type guard

fn prompt_exists(prompt_store: &PromptStore, id: &PromptId) -> bool {
    prompt_store
        .all_prompt_metadata()
        .iter()
        .any(|meta| &meta.id == id)
}

Try / catch

match prompt_store.load(id.clone(), cx).await {
    Ok(body) => Some(body),
    Err(e) if e.to_string() == "prompt not found" => None, // deleted concurrently
    Err(e) => { log::error!("failed to load prompt: {e:#}"); None }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/5c2fa5571568c157. Report an issue: GitHub.