{"record":{"id":"3d81fe728b1c1e61","repo":"BoundaryML/baml","slug":"baml-pack-failed-for-fixture","errorCode":null,"errorMessage":"`baml pack` failed for fixture {}","messagePattern":"`baml pack` failed for fixture (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/tools_size_gate/src/measure.rs","lineNumber":148,"sourceCode":"    let output = pack_output_path(workspace_root, name);\n    if let Some(parent) = output.parent() {\n        std::fs::create_dir_all(parent)\n            .with_context(|| format!(\"failed to create {}\", parent.display()))?;\n    }\n\n    eprintln!(\"  packing {} -> {}\", pack.function, output.display());\n    let status = Command::new(&cli_path)\n        .arg(\"pack\")\n        .arg(\"--file\")\n        .arg(&fixture)\n        .arg(&pack.function)\n        .arg(\"-o\")\n        .arg(&output)\n        .current_dir(workspace_root)\n        .status()\n        .with_context(|| format!(\"failed to run {} pack\", cli_path.display()))?;\n    if !status.success() {\n        bail!(\"`baml pack` failed for fixture {}\", fixture.display());\n    }\n\n    if !output.exists() {\n        bail!(\"pack produced no output at {}\", output.display());\n    }\n    Ok(output)\n}\n\n/// Deterministic output path for a packed artifact.\nfn pack_output_path(workspace_root: &Path, name: &str) -> PathBuf {\n    workspace_root\n        .join(\"target/size-gate\")\n        .join(exe_filename(name))\n}\n\n/// Find the built artifact in the target directory (public for --no-build mode).\npub(crate) fn locate_artifact_public(\n    workspace_root: &Path,","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/tools_size_gate/src/measure.rs#L130-L166","documentation":"After spawning `<cli> pack -i <fixture> -o <output>`, a non-zero exit status bails with this message naming the fixture. The actual pack errors are printed by the baml CLI on stderr before this bail is raised.","triggerScenarios":"The baml CLI's pack command fails on the fixture: invalid BAML source in the fixture, missing referenced generators/clients, or CLI runtime panics during packing.","commonSituations":"Fixture references a generator requiring env vars not set; BAML schema errors after a language change; incompatible fixture format after a CLI version bump; pack requires network for codegen and CI blocks it.","solutions":["Read the baml CLI's stderr output above this message for the root cause","Run the same pack command manually: <cli> pack -i <fixture> -o <output>","Fix the fixture's BAML source or any missing generator configuration","Ensure required env vars/network for codegen are available in CI"],"exampleFix":"// before: fixture references missing env\n// runtime \"python\" env { OPENAI_API_KEY }\n// after: provide it in the measure environment\nOPENAI_API_KEY=sk-... size-gate measure ...","handlingStrategy":"try-catch","validationCode":"// dry-run the pack command before measuring\nlet status = std::process::Command::new(&cli_path)\n    .args([\"pack\", \"-i\", &fixture, \"-o\", \"/tmp/probe-output\"])\n    .envs(required_codegen_env())\n    .status()?;\nif !status.success() { eprintln!(\"pack fails on fixture; see CLI stderr\"); std::process::exit(1); }","typeGuard":null,"tryCatchPattern":"if let Err(e) = run_baml_pack(ws, name, pack) {\n    if e.to_string().contains(\"baml pack` failed\") {\n        eprintln!(\"inspect the baml CLI stderr above; often missing env vars or invalid BAML in the fixture\");\n    }\n    return Err(e);\n}","preventionTips":["Provide all env vars the fixture's generators need in the measure environment","Validate fixture BAML files (baml CLI check) before the size run","Pin the baml CLI version used by the gate","Test pack locally on the same fixture after BAML schema changes"],"tags":["baml","pack","subprocess","ci"],"backgroundTag":"api-request-failed","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"}