{"record":{"id":"d3cc4837fa0b046e","repo":"BoundaryML/baml","slug":"the-go-generator-requires-sdk-import-path-module-baml-sdk","errorCode":null,"errorMessage":"the Go generator requires `--sdk-import-path <MODULE>/baml_sdk`","messagePattern":"the Go generator requires `--sdk-import-path <MODULE>/baml_sdk`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_cli/src/generate.rs","lineNumber":134,"sourceCode":"        let manifest = baml_db::manifest::parse(&content)\n            .with_context(|| format!(\"failed to parse {}\", toml_path.display()))?;\n        baml_db::manifest::package_name(&manifest, &toml_path)?;\n        // Every other manifest reader rejects these, so accepting them here\n        // would write a generator into a file that the next build refuses to\n        // load, reporting a failure that names neither this command nor the\n        // table it choked on.\n        baml_db::manifest::reject_stdlib_only_tables(&manifest, &toml_path)?;\n\n        let mut generator = Generator::from(self.output_type);\n        match (self.output_type, self.sdk_import_path.as_deref()) {\n            (OutputType::Go, Some(import_path)) if is_valid_go_import_path(import_path) => {\n                generator.sdk_import_path = Some(import_path.to_string());\n            }\n            (OutputType::Go, Some(import_path)) => {\n                anyhow::bail!(\"invalid Go SDK import path `{import_path}`\");\n            }\n            (OutputType::Go, None) => {\n                anyhow::bail!(\"the Go generator requires `--sdk-import-path <MODULE>/baml_sdk`\");\n            }\n            (_, Some(_)) => {\n                anyhow::bail!(\"`--sdk-import-path` is only valid for the Go generator\");\n            }\n            (_, None) => {}\n        }\n\n        let (updated, name) = add_generator_to_manifest(&content, &generator)\n            .with_context(|| format!(\"failed to update {}\", toml_path.display()))?;\n        std::fs::write(&toml_path, updated)\n            .with_context(|| format!(\"failed to write {}\", toml_path.display()))?;\n\n        Reporter::new().finish(\n            \"Added\",\n            format!(\"generator.{name} to {}\", toml_path.display()),\n        );\n        Ok(crate::ExitCode::Success)\n    }","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_cli/src/generate.rs#L116-L152","documentation":"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.","triggerScenarios":"Running the add-generator command with the Go output type selected but no `--sdk-import-path` flag provided.","commonSituations":"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.","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."],"exampleFix":"// before\nbaml generate add-generator --output-type go\n// after\nbaml generate add-generator --output-type go --sdk-import-path github.com/acme/app/baml_sdk","handlingStrategy":"validation","validationCode":"if (outputType === 'go' && !process.env.BAML_SDK_IMPORT_PATH) {\n  throw new Error('the Go generator requires --sdk-import-path <MODULE>/baml_sdk');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["cli","go","missing-argument"],"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"}