{"record":{"id":"ffeee1153d0772d8","repo":"BoundaryML/baml","slug":"invalid-go-sdk-import-path-import-path","errorCode":null,"errorMessage":"invalid Go SDK import path `{import_path}`","messagePattern":"invalid Go SDK import path `(.+?)`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_cli/src/generate.rs","lineNumber":131,"sourceCode":"\n        let content = std::fs::read_to_string(&toml_path)\n            .with_context(|| format!(\"failed to read {}\", toml_path.display()))?;\n        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()),","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_cli/src/generate.rs#L113-L149","documentation":"When adding a Go generator with `--sdk-import-path`, the CLI validates the import path with `is_valid_go_import_path`. If the value fails validation (wrong shape, invalid characters, not of the expected `<MODULE>/baml_sdk` form), this error is thrown with the offending value interpolated.","triggerScenarios":"`baml generate add-generator` with output type Go and `--sdk-import-path` set to a string that fails `is_valid_go_import_path` — e.g. relative paths, paths with spaces/invalid Go module characters, or missing the `/baml_sdk` suffix.","commonSituations":"Typos in the module path, passing a local filesystem path instead of a Go import path, forgetting the /baml_sdk suffix, or using Windows-style backslashes.","solutions":["Provide a full Go module path ending in /baml_sdk: --sdk-import-path github.com/me/myapp/baml_sdk.","Use forward slashes and valid Go module path characters (lowercase, no spaces).","Check the generated module's go.mod module name and append /baml_sdk to it.","If you don't have an import path yet, omit the flag and read the sibling error about the required format."],"exampleFix":"// before\n--sdk-import-path ./local/sdk\n// after\n--sdk-import-path github.com/acme/myapp/baml_sdk","handlingStrategy":"validation","validationCode":"const IMPORT_RE = /^[a-zA-Z0-9_.-]+(\\/[a-zA-Z0-9_.-]+)*\\/baml_sdk$/;\nif (!IMPORT_RE.test(importPath)) throw new Error(`invalid Go SDK import path \\`${importPath}\\``);","typeGuard":"function isValidGoImportPath(p: string): boolean {\n  return /^[\\w.-]+(\\/[\\w.-]+)+\\/baml_sdk$/.test(p);\n}","tryCatchPattern":null,"preventionTips":["Copy the module name verbatim from go.mod and append /baml_sdk.","Never pass filesystem paths; import paths use forward slashes.","Lint scripts that construct --sdk-import-path values."],"tags":["cli","go","validation"],"backgroundTag":"invalid-argument-format","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"}