#4869·baml

[bug] sdkgen_rust 0.19.0 exits 0 after skipping user functions, yielding a partial client

Author: sxlijinCreated Sep 14, 2026Updated Sep 14, 2026
Labelsbugrust

Product

BAML (output_type = "rust")

Describe the bug

On 0.19.0, the Rust generator can skip user-declared types and functions that it cannot represent, write a coherent-looking but partial client, print Generated rust_client (...), and exit 0. A build pipeline that trusts the exit status and success-shaped summary cannot distinguish this from complete generation.

This is the remaining failure mode from #4370 after 0.19.0 fixed generation of functions whose implicit throws contract includes ai.errors.Failure. It is independent of that fixed throws-contract bug.

Reproduction steps

Create baml.toml:

toml
[package]
name = "partial-client-probe"

[generator.rust_client]
output_type = "rust"
naming_convention = "preserve-case"
output_dir = "crates"

Create baml_src/main.baml:

baml
client Probe = openai.GenericClient.new(model = "m", base_url = env.BASE_URL, api_key = env.API_KEY);

class Route {
    command: "graph.query" | "facts.query"
}

function Vision(page: image) -> string {
    client: Probe
    prompt: `${page} Describe the image.`
}

function Query(text: string) -> Route {
    client: Probe
    prompt: `${text} ${ctx.output_format()}`
}

function Helper() -> string {
    "control"
}

Run:

bash
$ BAML_VERSION=0.19.0 baml generate
warning: skipped `user.Route`: field `command`: unsupported union arm: "graph.query"
warning: skipped `user.Query`: return: references skipped or unknown type `user.Route`
warning: skipped `user.Vision`: argument `page`: unsupported type: media (image)
   Generated rust_client (128 file(s), 0 identifier renames ...)
$ echo $?
0

The generated client contains only Helper and Helper_async among the three user functions (plus generated scaffolding). Vision provides a trigger independent of the dotted string-literal union; the Route/Query path also overlaps #4371.

Expected behavior

If generation skips any explicitly declared user type or function, baml generate should exit nonzero rather than report an ordinary successful generation. At minimum, the final summary should state prominently that the client is partial and how many user declarations were skipped.

Actual behavior

Generation exits 0 and prints the same success-shaped Generated rust_client (...) summary used for complete output. The only indication of missing API surface is a per-item warning, which is easy to miss among generator diagnostics.

Version and environment

  • BAML: published 0.19.0 GNU toolchain; baml_bridge = "=0.19.0"
  • Generator: Rust, naming_convention = "preserve-case"
  • OS: Linux x86_64
  • Retested: 2026-09-13

Originally confirmed in #4370's 0.19.0 retest: https://github.com/BoundaryML/baml/issues/4370#issuecomment-5654393275