{"record":{"id":"320758094695af76","repo":"BoundaryML/baml","slug":"script-target-has-no-function-and-there-is-no-implicit-entry","errorCode":null,"errorMessage":"script `{target}` has no `--function` and there is no implicit entry point. Add `--function <name>` to the script body.","messagePattern":"script `(.+?)` has no `--function` and there is no implicit entry point\\. Add `--function <name>` to the script body\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_cli/src/run_command.rs","lineNumber":535,"sourceCode":"                String::new(),\n                HashMap::new(),\n            )\n        } else {\n            let (toml_path, content) = Self::project_toml(&db, package);\n            let parsed = Self::parse_scripts(&content);\n            (toml_path, content, parsed)\n        };\n        self.validate_scripts(&engine, &scripts, &toml_path, &toml_content)?;\n\n        // Resolve to (function_name, effective_args, was_script).\n        let (function_name, effective_target_args, was_script) =\n            if let Some(script_tokens) = scripts.get(target) {\n                self.vlog(format_args!(\n                    \"Expanding script `{target}`: {script_tokens:?}\"\n                ));\n                let expansion = parse_script_body(script_tokens)?;\n                let func = expansion.function.ok_or_else(|| {\n                    anyhow!(\n                        \"script `{target}` has no `--function` and there is no implicit \\\n                         entry point. Add `--function <name>` to the script body.\"\n                    )\n                })?;\n                if engine.find_user_function(&func).is_none() {\n                    return Err(Self::function_not_found_error(&engine, &func));\n                }\n                let mut merged_args = expansion.extra_args;\n                merged_args.extend(self.target_args.iter().cloned());\n                (func, merged_args, true)\n            } else if engine.find_user_function(target).is_some() {\n                (target.to_string(), self.target_args.clone(), false)\n            } else {\n                return Err(Self::target_not_found_error_in(\n                    &scripts,\n                    &engine,\n                    target,\n                    &project_root,","sourceCodeStart":517,"sourceCodeEnd":553,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_cli/src/run_command.rs#L517-L553","documentation":"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.","triggerScenarios":"A `[scripts]` entry in `baml.toml` whose token body lacks a `--function <name>` flag, causing `parse_script_body(...).function` to be None.","commonSituations":"Hand-editing `baml.toml` scripts and forgetting the `--function` flag, or copying a script that relies on a removed implicit-entry-point behavior.","solutions":["Add `--function <name>` to the script body in `baml.toml`","Verify the script target name matches an intended entry in `[scripts]`"],"exampleFix":"# before (baml.toml)\n[scripts]\ndemo = [\"--verbose\"]\n# after\n[scripts]\ndemo = [\"--function\", \"MyFunction\", \"--verbose\"]","handlingStrategy":"validation","validationCode":"const body = scripts[name] ?? []; if (!body.includes('--function')) throw new Error(`script '${name}' needs --function <name>`);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include --function in every [scripts] body in baml.toml","Lint baml.toml scripts in CI","Do not rely on implicit entry points"],"tags":["cli","config","missing-argument","baml"],"backgroundTag":"missing-required-argument","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"}