{"record":{"id":"f6ab3b03eb5ab54a","repo":"astrid-runtime/astrid","slug":"runtime-tree-receipt-exceeds-max-receipt-bytes-b","errorCode":null,"errorMessage":"runtime tree receipt exceeds {MAX_RECEIPT_BYTES} bytes","messagePattern":"runtime tree receipt exceeds (.+?) bytes","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-kernel/src/runtime_tree_admit.rs","lineNumber":190,"sourceCode":"}\n\nfn read_receipt(path: &Path) -> io::Result<Option<RuntimeTreeReceipt>> {\n    let metadata = match fs::symlink_metadata(path) {\n        Ok(metadata) => metadata,\n        Err(error) if error.kind() == io::ErrorKind::NotFound => return Ok(None),\n        Err(error) => return Err(error),\n    };\n    if !metadata.is_file() {\n        return Err(io::Error::new(\n            io::ErrorKind::InvalidData,\n            format!(\n                \"runtime tree receipt is not a regular file: {}\",\n                path.display()\n            ),\n        ));\n    }\n    if metadata.len() > MAX_RECEIPT_BYTES {\n        return Err(io::Error::new(\n            io::ErrorKind::InvalidData,\n            format!(\"runtime tree receipt exceeds {MAX_RECEIPT_BYTES} bytes\"),\n        ));\n    }\n    astrid_core::platform_fs::validate_private_file(path)?;\n    let bytes = fs::read(path)?;\n    serde_json::from_slice(&bytes).map(Some).map_err(|error| {\n        io::Error::new(\n            io::ErrorKind::InvalidData,\n            format!(\"parse runtime tree receipt: {error}\"),\n        )\n    })\n}\n\nfn storage_error(error: impl std::error::Error + Send + Sync + 'static) -> io::Error {\n    io::Error::other(error)\n}\n","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-kernel/src/runtime_tree_admit.rs#L172-L208","documentation":"The runtime tree receipt file is larger than the compile-time MAX_RECEIPT_BYTES limit, so the kernel refuses to read it. The size cap protects against unbounded memory use and against corrupted or adversarial files placed at the receipt path. It is raised as InvalidData before the file is read.","triggerScenarios":"`read_receipt` checks `metadata.len() > MAX_RECEIPT_BYTES` on the receipt path (called by `admit_blocking`). Happens when an absurdly large file was put at the receipt path, or corruption appended garbage to a real receipt.","commonSituations":"A sync/restore tool wrote the wrong file at the receipt path; disk corruption; an experimental build wrote oversized receipts that a released build now rejects.","solutions":["Delete or move aside the oversized file and let the app regenerate the receipt on next admission","Verify what the file actually is (`file`, `head -c`) — it may not be a receipt at all","Restore a correctly-sized receipt from backup","Check for a version mismatch: downgrade/upgrade receipts written by mismatched app versions"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if let Ok(md) = std::fs::metadata(&receipt_path) {\n    if md.len() > MAX_RECEIPT_BYTES {\n        std::fs::rename(&receipt_path, receipt_path.with_extension(\"bak\"))?;\n    }\n}","typeGuard":null,"tryCatchPattern":"if msg.contains(\"exceeds\") && msg.contains(\"bytes\") {\n    // quarantine the oversized file and let the kernel regenerate\n    std::fs::remove_file(&path)?;\n    retry_admit()?;\n}","preventionTips":["Don't place arbitrary files at receipt paths","Keep app versions consistent between writers and readers","Verify restored homes for stray/oversized files"],"tags":["receipt","limit","validation"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}