{"record":{"id":"202c5dee45570b4a","repo":"gitbutlerapp/gitbutler","slug":"existing-gitmeta-key-transcript-key-is-missing","errorCode":null,"errorMessage":"existing GitMeta key '{transcript_key}' is missing","messagePattern":"existing GitMeta key '(.+?)' is missing","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-agentlog/src/gitmeta/read_support.rs","lineNumber":76,"sourceCode":"        return Ok(None);\n    };\n    let MetaValue::String(detail) = value else {\n        bail!(\"existing GitMeta key '{detail_key}' is not a string\");\n    };\n    serde_json::from_str(&detail)\n        .with_context(|| format!(\"existing GitMeta key '{detail_key}' has invalid JSON\"))\n        .map(Some)\n}\n\npub(super) fn read_transcript_entries(\n    handle: &SessionTargetHandle<'_>,\n    transcript_key: &str,\n) -> Result<Vec<ListEntry>> {\n    let Some(transcript_value) = handle\n        .get_value(transcript_key)\n        .with_context(|| format!(\"failed to read GitMeta key '{transcript_key}'\"))?\n    else {\n        bail!(\"existing GitMeta key '{transcript_key}' is missing\");\n    };\n    let MetaValue::List(transcript_entries) = transcript_value else {\n        bail!(\"existing GitMeta key '{transcript_key}' is not a list\");\n    };\n    Ok(transcript_entries)\n}\n\npub(super) fn transcript_records_by_hash<T>(\n    entries: Vec<ListEntry>,\n    needed_hashes: &std::collections::HashSet<String>,\n    mut parse_record: impl FnMut(&str) -> Option<(String, T)>,\n) -> HashMap<String, T> {\n    let mut records = HashMap::with_capacity(needed_hashes.len());\n    for entry in entries.into_iter().rev() {\n        let Some((record_hash, record)) = parse_record(&entry.value) else {\n            continue;\n        };\n        if !needed_hashes.contains(&record_hash) {","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-agentlog/src/gitmeta/read_support.rs#L58-L94","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Re-record or re-compact the session so the transcript list is written before hash lookups occur","Fix writer ordering: ensure the transcript is persisted before records-by-hash reads depend on it","Remove stale callers/records that reference the pruned transcript","Rebuild the session's GitMeta records if the transcript is permanently lost"],"exampleFix":"// before: caller assumes transcript exists\nlet records = records_by_hash(&repo_path, session, turn, &hash)?;\n// after: tolerate a missing transcript\nlet records = match records_by_hash(&repo_path, session, turn, &hash) {\n    Ok(r) => r,\n    Err(e) if e.to_string().contains(\"is missing\") => Vec::new(),\n    Err(e) => return Err(e),\n};","handlingStrategy":"try-catch","validationCode":"let transcript_key = format!(\"{session_prefix}:{turn_key}:transcript\");\nlet present = gitmeta_get(&repo_path, &transcript_key).is_some();\nif !present { /* re-record or skip hash lookup */ }","typeGuard":null,"tryCatchPattern":"match read_transcript_entries(handle, &transcript_key) {\n    Ok(entries) => entries,\n    Err(e) if e.to_string().contains(\"is missing\") => {\n        // transcript pruned; degrade gracefully\n        Vec::new()\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Persist the transcript before exposing turn records to hash lookups","Keep compaction and lookup tools on the same schema version","Don't prune transcript keys while records_by_hash lookups may still reference them","Rebuild session records if transcripts were lost to partial writes"],"tags":["gitmeta","missing-key","transcript"],"backgroundTag":"record-not-found","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}