{"record":{"id":"9bbce09e2e4116f5","repo":"BoundaryML/baml","slug":"kind-artifact-is-truncated","errorCode":null,"errorMessage":"{kind} artifact is truncated","messagePattern":"(.+?) artifact is truncated","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_artifact/src/lib.rs","lineNumber":117,"sourceCode":"impl fmt::Display for ArtifactKind {\n    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {\n        formatter.write_str(self.label())\n    }\n}\n\npub type Hash = [u8; 32];\n\n#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]\nstruct ArtifactHeader {\n    build_fingerprint: String,\n    kind: ArtifactKind,\n    payload_len: u64,\n    payload_hash: Hash,\n}\n\n#[derive(Debug, thiserror::Error)]\npub enum Error {\n    #[error(\"{kind} artifact is truncated\")]\n    Truncated { kind: ArtifactKind },\n    #[error(\n        \"{kind} is not a versioned BAML artifact; {}\",\n        kind.remediation()\n    )]\n    InvalidMagic { kind: ArtifactKind },\n    #[error(\"invalid {kind} artifact header: {message}\")]\n    InvalidHeader { kind: ArtifactKind, message: String },\n    #[error(\"expected {expected} artifact, found {actual}\")]\n    WrongKind {\n        expected: ArtifactKind,\n        actual: ArtifactKind,\n    },\n    #[error(\"{kind} artifact failed integrity validation\")]\n    InvalidPayloadHash { kind: ArtifactKind },\n    #[error(\n        \"{kind}: toolchain {artifact_fingerprint} / format {artifact_format}; this runtime: {runtime_fingerprint} / format {runtime_format} — {remediation}\"\n    )]","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_artifact/src/lib.rs#L99-L135","documentation":"`Error::Truncated` in baml_artifact indicates that the artifact blob ended before the header and payload declared by the versioned envelope. The reader parsed the length fields but the buffer ran out of bytes, so the artifact cannot be trusted or deserialized.","triggerScenarios":"Decoding an artifact (via the crate's decode path) whose byte buffer is shorter than its declared header+payload length; passing a partially-written or clipped file to the artifact decoder.","commonSituations":"A download was interrupted leaving a partial artifact file; a build/packaging step wrote the file but crashed before flushing; copying artifacts with tools that truncate (e.g., interrupted scp/rsync); reading a file while a concurrent writer still has it open.","solutions":["Regenerate or re-download the artifact — the file is unrecoverable.","Verify the artifact file size matches what the producing toolchain reported (checksum/size manifest).","Re-run the build step that emits the artifact, ensuring writes are flushed and atomic (write to temp then rename).","Check disk space and filesystem health on the machine that stored the artifact."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const stat = fs.statSync(artifactPath);\nconst expected = manifest.artifacts['ir'].sizeBytes;\nif (stat.size !== expected) {\n  throw new Error(`artifact truncated: ${stat.size} of ${expected} bytes; re-download`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify artifact size/checksum immediately after download.","Write artifacts atomically (temp file + rename) in build scripts.","Avoid transferring binary artifacts in text/ASCII mode."],"tags":["artifact","serialization","truncated-data","integrity"],"backgroundTag":"invalid-json-response","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}