{"record":{"id":"551145fbd6528dcd","repo":"BoundaryML/baml","slug":"sdk-import-path-is-only-valid-for-the-go-generator","errorCode":null,"errorMessage":"`--sdk-import-path` is only valid for the Go generator","messagePattern":"`--sdk-import-path` is only valid for the Go generator","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_cli/src/generate.rs","lineNumber":137,"sourceCode":"        // 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    }\n}\n\nfn parse_add_output_type(value: &str) -> Result<OutputType, String> {","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_cli/src/generate.rs#L119-L155","documentation":"Argument-compatibility guard in `baml generate`: the --sdk-import-path flag was supplied with a non-Go output type. The flag only configures the import path prefix emitted by the Go code generator; for every other generator it is meaningless, and accepting it would embed a Go-specific setting into a generated manifest that other generators' readers reject anyway.","triggerScenarios":"`baml generate add-generator --output-type python --sdk-import-path ...` (or typescript, or no output type) — any non-Go output type combined with `--sdk-import-path`.","commonSituations":"Copy-pasting a Go command template while editing the output type; scripting that always appends --sdk-import-path regardless of target language.","solutions":["Remove --sdk-import-path when the output type is not Go.","Switch --output-type to go if you actually intend to generate a Go SDK.","In scripts, add the flag conditionally only when output type is go."],"exampleFix":"// before\nbaml generate add-generator --output-type python --sdk-import-path github.com/x/y/baml_sdk\n// after\nbaml generate add-generator --output-type python","handlingStrategy":"validation","validationCode":"const args = ['add-generator', '--output-type', outputType];\nif (outputType === 'go') args.push('--sdk-import-path', goModule + '/baml_sdk');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build CLI argument arrays conditionally instead of appending all flags always.","Add a script check that rejects --sdk-import-path when output type is not go.","Keep one command template per target language."],"tags":["cli","flags","conflicting-options"],"backgroundTag":"mutually-exclusive-options","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"}