{"record":{"id":"45c132187c23cf2a","repo":"Hmbown/CodeWhale","slug":"fleet-artifact-exceeds-the-16-mib-limit","errorCode":null,"errorMessage":"Fleet artifact exceeds the 16 MiB limit","messagePattern":"Fleet artifact exceeds the 16 MiB limit","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/fleet/artifacts.rs","lineNumber":23,"sourceCode":"#[cfg(test)]\nuse std::fs::File;\nuse std::io::{self, Read};\nuse std::path::Path;\n\nuse super::files::WorkspaceFile;\npub(crate) use super::files::path_is_confined;\n\nuse anyhow::{Context, Result, ensure};\nuse codewhale_protocol::fleet::FleetArtifactRef;\nuse sha2::{Digest, Sha256};\n\n// The HTTP preview stays small; verifying a larger artifact streams its digest\n// without retaining all bytes. The writer shares the ceiling so it cannot\n// publish an artifact the evidence reader is unable to verify.\nconst MAX_ARTIFACT_BYTES: u64 = 16 * 1024 * 1024;\n\npub(crate) fn write(workspace: &Path, relative: &Path, bytes: &[u8]) -> Result<()> {\n    ensure!(\n        bytes.len() as u64 <= MAX_ARTIFACT_BYTES,\n        \"Fleet artifact exceeds the 16 MiB limit\"\n    );\n    let parent = WorkspaceFile::open(workspace, relative, true)?;\n    match parent.publish(bytes) {\n        Ok(()) => Ok(()),\n        Err(error) if error.kind() == io::ErrorKind::AlreadyExists => {\n            let existing = parent.open_file()?;\n            let mut saved = Vec::new();\n            existing\n                .take(bytes.len() as u64 + 1)\n                .read_to_end(&mut saved)?;\n            ensure!(\n                saved == bytes,\n                \"An existing Fleet artifact contains different bytes\"\n            );\n            Ok(())\n        }","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/fleet/artifacts.rs#L5-L41","documentation":"Fleet artifact publication enforces a 16 MiB ceiling (MAX_ARTIFACT_BYTES) shared with the evidence reader, so the writer can never publish an artifact that read_verified would be unable to verify. write checks the byte length before creating the file and fails closed if exceeded.","triggerScenarios":"Calling fleet::artifacts::write(workspace, relative, bytes) with a bytes slice longer than 16 * 1024 * 1024 bytes.","commonSituations":"Dumping a large log, model output, or binary blob into the Fleet workspace instead of a summarized preview; accumulating outputs that were small in tests but large in production runs.","solutions":["Truncate or summarize the payload below 16 MiB before calling write (e.g. keep a head/tail slice with an elision marker).","Store oversized content outside the Fleet workspace (object storage, temp file) and write a small reference/metadata artifact instead.","Compress the bytes before publication if the information must be kept.","If 16 MiB is genuinely too small for your workflow, this is a deliberate product limit — raise it in artifacts.rs only together with the verification path."],"exampleFix":"// before\nartifacts::write(ws, &path, &huge_bytes)?; // panics-fails over 16 MiB\n// after\nlet trimmed = &huge_bytes[..huge_bytes.len().min(16 * 1024 * 1024 - 1)];\nartifacts::write(ws, &path, trimmed)?;","handlingStrategy":"validation","validationCode":"const MAX: usize = 16 * 1024 * 1024;\nif bytes.len() > MAX {\n    bytes = summarize_or_compress(bytes); // keep under ceiling before write\n}\nartifacts::write(ws, &path, bytes)?;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Summarize or compress large outputs before publishing artifacts.","Check payload size in CI for pipeline steps that generate artifacts.","Store oversized blobs externally and publish a reference artifact."],"tags":["fleet","artifacts","size-limit","validation"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T06:17:15.046Z"}