BoundaryML/baml · error

script `{target}` has no `--function` and there is no implic

Error message

script `{target}` has no `--function` and there is no implicit entry point. Add `--function <name>` to the script body.

What it means

When running a named script target, the script body (from `[scripts]` in `baml.toml`) is parsed as tokens and must specify which function to run. If the expansion has no `--function` (and there is no implicit entry point), the CLI errors out.

Source

Thrown at baml_language/crates/baml_cli/src/run_command.rs:535

                String::new(),
                HashMap::new(),
            )
        } else {
            let (toml_path, content) = Self::project_toml(&db, package);
            let parsed = Self::parse_scripts(&content);
            (toml_path, content, parsed)
        };
        self.validate_scripts(&engine, &scripts, &toml_path, &toml_content)?;

        // Resolve to (function_name, effective_args, was_script).
        let (function_name, effective_target_args, was_script) =
            if let Some(script_tokens) = scripts.get(target) {
                self.vlog(format_args!(
                    "Expanding script `{target}`: {script_tokens:?}"
                ));
                let expansion = parse_script_body(script_tokens)?;
                let func = expansion.function.ok_or_else(|| {
                    anyhow!(
                        "script `{target}` has no `--function` and there is no implicit \
                         entry point. Add `--function <name>` to the script body."
                    )
                })?;
                if engine.find_user_function(&func).is_none() {
                    return Err(Self::function_not_found_error(&engine, &func));
                }
                let mut merged_args = expansion.extra_args;
                merged_args.extend(self.target_args.iter().cloned());
                (func, merged_args, true)
            } else if engine.find_user_function(target).is_some() {
                (target.to_string(), self.target_args.clone(), false)
            } else {
                return Err(Self::target_not_found_error_in(
                    &scripts,
                    &engine,
                    target,
                    &project_root,

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Add `--function <name>` to the script body in `baml.toml`
  2. Verify the script target name matches an intended entry in `[scripts]`

Example fix

# before (baml.toml)
[scripts]
demo = ["--verbose"]
# after
[scripts]
demo = ["--function", "MyFunction", "--verbose"]
Defensive patterns

Strategy: validation

Validate before calling

const body = scripts[name] ?? []; if (!body.includes('--function')) throw new Error(`script '${name}' needs --function <name>`);

Prevention

When it happens

Trigger: A `[scripts]` entry in `baml.toml` whose token body lacks a `--function <name>` flag, causing `parse_script_body(...).function` to be None.

Common situations: Hand-editing `baml.toml` scripts and forgetting the `--function` flag, or copying a script that relies on a removed implicit-entry-point behavior.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/320758094695af76. Report an issue: GitHub.