{"record":{"id":"dc748d1ec577aaba","repo":"BoundaryML/baml","slug":"expected-expected-artifact-found-actual","errorCode":null,"errorMessage":"expected {expected} artifact, found {actual}","messagePattern":"expected (.+?) artifact, found (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_artifact/src/lib.rs","lineNumber":126,"sourceCode":"struct 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,\n    },\n    #[error(\"failed to encode {kind}: {message}\")]","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_artifact/src/lib.rs#L108-L144","documentation":"`Error::WrongKind` is returned when an artifact is a valid versioned BAML artifact, but of a different `ArtifactKind` than the one requested by the decoder. For example, passing a client-library artifact where a runtime manifest artifact is expected.","triggerScenarios":"Calling the artifact decode/validate API with an `expected` kind that does not match the `actual` kind stored in the envelope; loading the wrong generated file into a consumer that expects a specific artifact type.","commonSituations":"Wiring the wrong output path in the build pipeline (e.g., feeding the generated client where the IR manifest goes); stale config pointing at an old artifact slot; a renamed or reordered artifact output directory.","solutions":["Point the consumer at the artifact file whose kind matches what it expects (check the generator's output paths).","Regenerate all artifacts so every consumer finds its matching kind.","Fix build configuration (output dirs / file names) so each artifact kind is written where the runtime reads it."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const actual = readArtifactKind(path);\nif (actual !== expectedKind) {\n  throw new Error(`wrong artifact at ${path}: expected ${expectedKind}, found ${actual}`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Wire each consumer to the exact artifact output path for its kind.","Regenerate all artifact kinds together after build-config changes.","Name artifact files by kind to prevent mix-ups."],"tags":["artifact","type-mismatch","build-pipeline"],"backgroundTag":"incompatible-source-type","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"}