{"record":{"id":"9cb327488b884aa1","repo":"BoundaryML/baml","slug":"invalid-kind-artifact-header-message","errorCode":null,"errorMessage":"invalid {kind} artifact header: {message}","messagePattern":"invalid (.+?) artifact header: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_artifact/src/lib.rs","lineNumber":124,"sourceCode":"\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    )]\n    Incompatible {\n        kind: ArtifactKind,\n        artifact_fingerprint: String,\n        artifact_format: u32,\n        runtime_fingerprint: &'static str,\n        runtime_format: u32,\n        remediation: &'static str,","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_artifact/src/lib.rs#L106-L142","documentation":"`Error::InvalidHeader` is raised when the artifact's magic is present but a header field fails validation — e.g., a malformed version, length, hash, or kind field — with a free-form `message` describing the exact problem. It indicates a structurally broken versioned envelope.","triggerScenarios":"Decoding an artifact whose header fields are corrupt or nonsensical (bad lengths, unknown header version, mismatched kind marker) via the artifact decode path.","commonSituations":"Bit rot or partial corruption on disk; hand-edited or post-processed artifact files; a bug in a custom producer writing the envelope; mixing headers/fragments from two different artifacts.","solutions":["Regenerate the artifact with the BAML toolchain rather than repairing it by hand.","Re-download the artifact and verify its checksum against the publisher's manifest.","Check the `message` field for the specific invalid header field and fix the producing pipeline accordingly.","Ensure no post-processing step (minifier, packer, text-mode transfer) is rewriting the binary artifact."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (artifactBytes.length < HEADER_MIN_LEN) {\n  throw new Error('artifact too small to contain a valid header; regenerate');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never hand-edit or post-process binary artifacts.","Checksum artifacts after generation and before consumption.","Use atomic writes in the producing pipeline."],"tags":["artifact","header","serialization","corruption"],"backgroundTag":"schema-validation-failed","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"}