BoundaryML/baml · error
the Go generator requires `--sdk-import-path <MODULE>/baml_s
Error message
the Go generator requires `--sdk-import-path <MODULE>/baml_sdk`
What it means
The Go code generator requires knowing the Go import path under which the generated BAML SDK lives. When output type is Go and `--sdk-import-path` was not supplied at all, this error explains the required `<MODULE>/baml_sdk` format.
Source
Thrown at baml_language/crates/baml_cli/src/generate.rs:134
let manifest = baml_db::manifest::parse(&content)
.with_context(|| format!("failed to parse {}", toml_path.display()))?;
baml_db::manifest::package_name(&manifest, &toml_path)?;
// Every other manifest reader rejects these, so accepting them here
// would write a generator into a file that the next build refuses to
// load, reporting a failure that names neither this command nor the
// table it choked on.
baml_db::manifest::reject_stdlib_only_tables(&manifest, &toml_path)?;
let mut generator = Generator::from(self.output_type);
match (self.output_type, self.sdk_import_path.as_deref()) {
(OutputType::Go, Some(import_path)) if is_valid_go_import_path(import_path) => {
generator.sdk_import_path = Some(import_path.to_string());
}
(OutputType::Go, Some(import_path)) => {
anyhow::bail!("invalid Go SDK import path `{import_path}`");
}
(OutputType::Go, None) => {
anyhow::bail!("the Go generator requires `--sdk-import-path <MODULE>/baml_sdk`");
}
(_, Some(_)) => {
anyhow::bail!("`--sdk-import-path` is only valid for the Go generator");
}
(_, None) => {}
}
let (updated, name) = add_generator_to_manifest(&content, &generator)
.with_context(|| format!("failed to update {}", toml_path.display()))?;
std::fs::write(&toml_path, updated)
.with_context(|| format!("failed to write {}", toml_path.display()))?;
Reporter::new().finish(
"Added",
format!("generator.{name} to {}", toml_path.display()),
);
Ok(crate::ExitCode::Success)
}View on GitHub (pinned to bd85ce9dee)
Solutions
- Add the flag: --sdk-import-path <your-go-module>/baml_sdk (e.g. github.com/acme/app/baml_sdk).
- Look up your module name in go.mod (`module ...` line) and append /baml_sdk.
- If you actually target Python/TypeScript, change the output type instead of using Go.
Example fix
// before baml generate add-generator --output-type go // after baml generate add-generator --output-type go --sdk-import-path github.com/acme/app/baml_sdk
Defensive patterns
Strategy: validation
Validate before calling
if (outputType === 'go' && !process.env.BAML_SDK_IMPORT_PATH) {
throw new Error('the Go generator requires --sdk-import-path <MODULE>/baml_sdk');
} Prevention
- Read the module line in go.mod before generating a Go client.
- Encode the flag in project bootstrap scripts for Go targets.
- Document the required flag in your team's generator command templates.
When it happens
Trigger: Running the add-generator command with the Go output type selected but no `--sdk-import-path` flag provided.
Common situations: First-time Go users unaware the Go generator has this extra required option; copying a command from Python/TypeScript examples where the flag doesn't exist; automation scripts migrating output type from python to go without adding the flag.
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
- usage: baml toolchain install <canary|nightly|version>
- usage: baml toolchain use <canary|nightly|version|path>
- usage: baml toolchain pin <canary|nightly|version|path>
- usage: baml toolchain uninstall <version>
- invalid Go SDK import path `{import_path}`
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/d3cc4837fa0b046e.
Report an issue: GitHub.