{"record":{"id":"cf747e53c107b0fa","repo":"BoundaryML/baml","slug":"invalid-package-interface-message","errorCode":null,"errorMessage":"invalid package interface: {message}","messagePattern":"invalid package interface: (.+?)","errorType":"exception","errorClass":"SourceRootError","httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_db/src/db.rs","lineNumber":103,"sourceCode":"    /// A live root already sits at this (canonical) path.\n    #[error(\"a source root already exists at this path\")]\n    PathTaken(SourceRoot),\n    /// The edge name is one no package may declare: a stdlib package's name\n    /// (already an implicit edge of every package) or a source-level\n    /// qualifier (`root`, `env`).\n    #[error(\"dependency name `{name}` is reserved\")]\n    ReservedDependencyName { name: Name },\n    /// The root already has an edge under this name.\n    #[error(\"dependency `{name}` is declared twice\")]\n    DuplicateDependencyName { name: Name },\n    /// The edge names a root that is not live in this database.\n    #[error(\"dependency `{name}` names a source root that does not exist\")]\n    UnknownDependencyRoot { name: Name },\n    /// The edge would make the dependency graph cyclic.\n    #[error(\"dependency `{name}` would form a dependency cycle\")]\n    DependencyCycle { name: Name },\n    /// The interface bytes are not a valid `PackageInterface` artifact.\n    #[error(\"invalid package interface: {message}\")]\n    InvalidInterface { message: String },\n}\n\n/// The main database for BAML projects.\n///\n/// `ProjectDatabase` owns the Salsa storage directly and implements all the\n/// compiler `Db` traits. It provides high-level APIs for:\n/// - Source-root management (add/remove roots, longest-prefix lookup)\n/// - File management within a root (add/update/remove files)\n/// - Diagnostics collection via `check()`\n///\n/// ## Example\n///\n/// ```ignore\n/// let mut db = ProjectDatabase::new();\n/// db.ensure_stdlib_sources();\n/// let root = db.add_source_root(SourceRootSpec::new(\"/my/project\", SourceRootKind::Workspace))?;\n/// db.add_or_update_file_in(root, Path::new(\"/my/project/main.baml\"), \"class Foo {}\");","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_db/src/db.rs#L85-L121","documentation":"Part of `SourceRootError`. Thrown when the interface bytes attached to a source root via `served_from(bytes)` are not a valid `PackageInterface` artifact (the borsh-serialized precompiled interface for the package). The database cannot reconstruct the package's public surface from them.","triggerScenarios":"Calling `SourceRootSpec::served_from` with bytes that fail `PackageInterface` deserialization, then `add_source_root`; typically happens when `StdlibProvenance::Interface` bytes come from `ensure_precompiled_stdlib`.","commonSituations":"Stale or truncated precompiled stdlib artifacts from an older compiler version; bytes corrupted in transit/storage; passing arbitrary bytes (e.g. source text) instead of serialized interfaces.","solutions":["Regenerate the precompiled stdlib interface bytes with the matching compiler version.","Verify the bytes are the full borsh-encoded `PackageInterface` for the package.","Ensure the artifact pipeline isn't truncating or corrupting the byte blobs."],"exampleFix":"// before\nlet bytes = read_file(\"stdlib/core.interface.bin\"); // stale v0.1 artifact\n// after\nlet bytes = regenerate_interface(\"core\"); // built with current compiler\nspec.served_from(bytes)","handlingStrategy":"validation","validationCode":"fn interfaces_look_valid(map: &BTreeMap<String, Vec<u8>>) -> bool {\n    !map.is_empty() && map.values().all(|b| !b.is_empty())\n}","typeGuard":null,"tryCatchPattern":"// add_source_root returns Result; treat InvalidInterface as a corrupted-artifact case\nmatch db.add_source_root(spec) {\n    Err(SourceRootError::InvalidInterface { message }) => eprintln!(\"regenerate interface bytes: {message}\"),\n    Err(e) => eprintln!(\"root error: {e}\"),\n    Ok(root) => root,\n}","preventionTips":["Generate interface bytes with the same compiler version that consumes them.","Round-trip a borsh encode/decode check on artifacts before shipping them.","Store interfaces with integrity checks to catch truncation."],"tags":["serialization","rust","borsh","precompiled-artifact"],"backgroundTag":"invalid-argument-format","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}