{"record":{"id":"14207e98653f9958","repo":"github/copilot-sdk","slug":"module-s-not-found-in-go-mod","errorCode":null,"errorMessage":"module %s not found in go.mod","messagePattern":"module (.+?) not found in go\\.mod","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/cmd/bundler/main.go","lineNumber":296,"sourceCode":"\t}\n\n\treturn cliVersion, nil\n}\n\n// getSDKVersion runs \"go list -m\" to get the copilot-sdk version from go.mod\nfunc getSDKVersion() (string, error) {\n\tcmd := exec.Command(\"go\", \"list\", \"-m\", \"-f\", \"{{.Version}}\", sdkModule)\n\toutput, err := cmd.Output()\n\tif err != nil {\n\t\tif exitErr, ok := err.(*exec.ExitError); ok {\n\t\t\treturn \"\", fmt.Errorf(\"go list failed: %s\", string(exitErr.Stderr))\n\t\t}\n\t\treturn \"\", err\n\t}\n\n\tversion := strings.TrimSpace(string(output))\n\tif version == \"\" {\n\t\treturn \"\", fmt.Errorf(\"module %s not found in go.mod\", sdkModule)\n\t}\n\n\treturn version, nil\n}\n\n// fetchCLIVersionFromRepo fetches package.json from GitHub and extracts the CLI version.\nfunc fetchCLIVersionFromRepo(sdkVersion string) (string, error) {\n\t// Convert Go module version to Git ref\n\t// v0.1.0 -> v0.1.0\n\t// v0.1.0-beta.1 -> v0.1.0-beta.1\n\t// v0.0.0-20240101120000-abcdef123456 -> abcdef123456 (pseudo-version)\n\tgitRef := sdkVersion\n\n\t// Pseudo-versions end with a 12-character commit hash.\n\t// Format: vX.Y.Z-yyyymmddhhmmss-abcdefabcdef\n\tif idx := strings.LastIndex(sdkVersion, \"-\"); idx != -1 {\n\t\tsuffix := sdkVersion[idx+1:]\n\t\t// Use the commit hash when present so we fetch the exact source snapshot.","sourceCodeStart":278,"sourceCodeEnd":314,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/go/cmd/bundler/main.go#L278-L314","documentation":"After `go list -m` succeeds, getSDKVersion trims the output; if it is empty it concludes the copilot-sdk module is not recorded in go.mod and returns this error. `go list -m` printing an empty version means the module path cannot be resolved to a concrete version in this build.","triggerScenarios":"sdkModule is not present in the require graph (never added, or only present as an indirect/local replace without a version), producing empty output from `go list -m -f {{.Version}}`.","commonSituations":"Fresh project where copilot-sdk was never `go get`-ed; a replace directive pointing at a path with no pseudo-version; vendored setups missing the module metadata.","solutions":["Add the dependency: `go get <copilot-sdk-module>@latest`","Verify the require line exists in go.mod and has a version","Run `go mod tidy` and confirm `go list -m <sdkModule>` prints a version","Re-run the bundler"],"exampleFix":"// before go.mod: (no copilot-sdk entry)\n// after go.mod:\n// require github.com/github/copilot-sdk v0.5.0","handlingStrategy":"validation","validationCode":"out, _ := exec.Command(\"go\", \"list\", \"-m\", \"-f\", \"{{.Version}}\", sdkModule).Output()\nif len(bytes.TrimSpace(out)) == 0 {\n    return errors.New(\"add copilot-sdk with: go get \" + sdkModule + \"@latest\")\n}","typeGuard":null,"tryCatchPattern":"if _, err := getSDKVersion(); err != nil {\n    if strings.Contains(err.Error(), \"not found in go.mod\") {\n        exec.Command(\"go\", \"get\", sdkModule+\"@latest\").Run()\n    }\n}","preventionTips":["Add copilot-sdk as a direct requirement before bundling","Check go.mod's require block during project setup","Avoid bare replace directives without a resolvable version"],"tags":["go","modules","gomod","dependency"],"backgroundTag":"missing-dependency","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}