{"record":{"id":"4ea4098f2c6105f2","repo":"dagger/dagger","slug":"existing-go-mod-path-q-does-not-match-the-module","errorCode":null,"errorMessage":"existing go.mod path %q does not match the module's name %q","messagePattern":"existing go\\.mod path %q does not match the module's name %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/codegen/generator/go/generate_module.go","lineNumber":210,"sourceCode":"\tmoduleConfig := g.Config.ModuleConfig\n\n\tvar needsRegen bool\n\n\tvar daggerModPath string\n\tvar goMod *modfile.File\n\n\tmodname := fmt.Sprintf(\"dagger/%s\", strcase.ToKebab(moduleConfig.ModuleName))\n\t// check for a go.mod already for the dagger module\n\tif content, err := os.ReadFile(filepath.Join(g.Config.OutputDir, moduleConfig.ModuleSourcePath, \"go.mod\")); err == nil {\n\t\tdaggerModPath = moduleConfig.ModuleSourcePath\n\n\t\tgoMod, err = modfile.ParseLax(\"go.mod\", content, nil)\n\t\tif err != nil {\n\t\t\treturn nil, false, fmt.Errorf(\"parse go.mod: %w\", err)\n\t\t}\n\n\t\tif moduleConfig.IsInit && goMod.Module.Mod.Path != modname {\n\t\t\treturn nil, false, fmt.Errorf(\"existing go.mod path %q does not match the module's name %q\", goMod.Module.Mod.Path, modname)\n\t\t}\n\t}\n\n\t// could not find a go.mod, so we can init a basic one\n\tif goMod == nil {\n\t\tdaggerModPath = moduleConfig.ModuleSourcePath\n\t\tgoMod = new(modfile.File)\n\n\t\tgoMod.AddModuleStmt(modname)\n\t\tgoMod.AddGoStmt(goVersion)\n\n\t\tneedsRegen = true\n\t}\n\n\t// sanity check the parsed go version\n\t//\n\t// if this fails, then the go.mod version is too high! and in that case, we\n\t// won't be able to load the resulting package","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/cmd/codegen/generator/go/generate_module.go#L192-L228","documentation":"Raised during module init (moduleConfig.IsInit) when an existing go.mod is found but its module path does not match the expected dagger/<kebab-module-name>. Guards against generating into a directory already belonging to a differently named Go module.","triggerScenarios":"Thrown at cmd/codegen/generator/go/generate_module.go:210 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Align the go.mod module directive with the module name in dagger.json","Remove the stale go.mod if it belongs to an old/different module","Rename the Dagger module to match the existing go.mod path"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}