gitbutlerapp/gitbutler · error

existing GitMeta key

Error message

existing GitMeta key '{transcript_key}' is missing

What it means

read_transcript_entries reads a transcript key that callers (session_file_edit_hashes_by_turn, records_by_hash, compact_records_by_hash) treat as mandatory: the transcript is expected to exist when the turn/session record is being read. Unlike the turns-list readers, an absent transcript key is a hard error here, indicating the transcript payload referenced by the caller was never written or has been pruned.

Solutions

  1. Re-record or re-compact the session so the transcript list is written before hash lookups occur
  2. Fix writer ordering: ensure the transcript is persisted before records-by-hash reads depend on it
  3. Remove stale callers/records that reference the pruned transcript
  4. Rebuild the session's GitMeta records if the transcript is permanently lost

Example fix

// before: caller assumes transcript exists
let records = records_by_hash(&repo_path, session, turn, &hash)?;
// after: tolerate a missing transcript
let records = match records_by_hash(&repo_path, session, turn, &hash) {
    Ok(r) => r,
    Err(e) if e.to_string().contains("is missing") => Vec::new(),
    Err(e) => return Err(e),
};
Defensive patterns

Strategy: try-catch

Validate before calling

let transcript_key = format!("{session_prefix}:{turn_key}:transcript");
let present = gitmeta_get(&repo_path, &transcript_key).is_some();
if !present { /* re-record or skip hash lookup */ }

Try / catch

match read_transcript_entries(handle, &transcript_key) {
    Ok(entries) => entries,
    Err(e) if e.to_string().contains("is missing") => {
        // transcript pruned; degrade gracefully
        Vec::new()
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: records_by_hash / session_file_edit_hashes_by_turn / compact_records_by_hash calling read_transcript_entries when handle.get_value(transcript_key) returns None — the transcript list for the targeted turn is absent while its records are being looked up.

Common situations: Compaction dropped the transcript but callers still look up records by hash; a partial write created the turn reference without the transcript; manual pruning of GitMeta keys; storage corruption or version-skewed writers.

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.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/202c5dee45570b4a. Report an issue: GitHub.

Appendix: source

Thrown at crates/but-agentlog/src/gitmeta/read_support.rs:76

        return Ok(None);
    };
    let MetaValue::String(detail) = value else {
        bail!("existing GitMeta key '{detail_key}' is not a string");
    };
    serde_json::from_str(&detail)
        .with_context(|| format!("existing GitMeta key '{detail_key}' has invalid JSON"))
        .map(Some)
}

pub(super) fn read_transcript_entries(
    handle: &SessionTargetHandle<'_>,
    transcript_key: &str,
) -> Result<Vec<ListEntry>> {
    let Some(transcript_value) = handle
        .get_value(transcript_key)
        .with_context(|| format!("failed to read GitMeta key '{transcript_key}'"))?
    else {
        bail!("existing GitMeta key '{transcript_key}' is missing");
    };
    let MetaValue::List(transcript_entries) = transcript_value else {
        bail!("existing GitMeta key '{transcript_key}' is not a list");
    };
    Ok(transcript_entries)
}

pub(super) fn transcript_records_by_hash<T>(
    entries: Vec<ListEntry>,
    needed_hashes: &std::collections::HashSet<String>,
    mut parse_record: impl FnMut(&str) -> Option<(String, T)>,
) -> HashMap<String, T> {
    let mut records = HashMap::with_capacity(needed_hashes.len());
    for entry in entries.into_iter().rev() {
        let Some((record_hash, record)) = parse_record(&entry.value) else {
            continue;
        };
        if !needed_hashes.contains(&record_hash) {

View on GitHub (pinned to 58e5313667)