{"record":{"id":"685fb0e928ca310f","repo":"github/copilot-sdk","slug":"failed-to-add-zstd-dependency-w-s","errorCode":null,"errorMessage":"failed to add zstd dependency: %w\n%s","messagePattern":"failed to add zstd dependency: %w\n(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/cmd/bundler/main.go","lineNumber":1279,"sourceCode":"\tfile, err := os.Open(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer file.Close()\n\n\th := sha256.New()\n\tif _, err := io.Copy(h, file); err != nil {\n\t\treturn nil, err\n\t}\n\treturn h.Sum(nil), nil\n}\n\n// ensureZstdDependency makes sure the module has the zstd dependency for generated code.\nfunc ensureZstdDependency() error {\n\tcmd := exec.Command(\"go\", \"mod\", \"tidy\")\n\toutput, err := cmd.CombinedOutput()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to add zstd dependency: %w\\n%s\", err, strings.TrimSpace(string(output)))\n\t}\n\treturn nil\n}\n\n// checkEmbeddedVersion checks if an embedded CLI version exists and compares it with the detected version.\nfunc checkEmbeddedVersion(detectedVersion, goos, goarch, outputDir string) error {\n\t// Look for the generated Go file for this platform\n\tgoFileName := fmt.Sprintf(\"zcopilot_%s_%s.go\", goos, goarch)\n\tgoFilePath := filepath.Join(outputDir, goFileName)\n\n\tdata, err := os.ReadFile(goFilePath)\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\t// No existing embedded version, nothing to check\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"failed to read existing Go file: %w\", err)\n\t}","sourceCodeStart":1261,"sourceCodeEnd":1297,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/go/cmd/bundler/main.go#L1261-L1297","documentation":"ensureZstdDependency runs 'go mod tidy' so the generated module depends on the zstd package needed by generated code. If the tidy command exits non-zero, the error plus the combined command output are wrapped with this message. It indicates the module's go.mod/go.sum could not be reconciled.","triggerScenarios":"Running the bundler's dependency step when 'go mod tidy' fails: go not on PATH, missing or corrupt go.mod/go.sum, network failure fetching modules, conflicting requirements, or a Go toolchain version mismatch (go directive newer than installed toolchain).","commonSituations":"Offline CI runner with no module proxy access; private module requiring credentials; go.mod edited by hand leaving unsatisfiable requires; GOPROXY misconfigured; running with an older Go than the module requires.","solutions":["Run 'go mod tidy' manually in the module dir and read the combined output appended to the error","Confirm 'go' is installed and on PATH, and the toolchain version satisfies the go.mod go directive","Check network/proxy access: GOPROXY, GOPRIVATE, and any private-repo auth for module downloads","If go.sum/go.mod is corrupted, restore from VCS or run 'go mod download' then 'go mod tidy'"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// ensure go is available before bundling\nif _, err := exec.LookPath(\"go\"); err != nil { return errors.New(\"go toolchain required on PATH\") }","typeGuard":null,"tryCatchPattern":"// Go\nif err := ensureZstdDependency(); err != nil {\n\tlog.Fatalf(\"zstd dependency step failed: %v — inspect 'go mod tidy' output above\", err)\n}","preventionTips":["Keep go.mod/go.sum committed and valid","Run bundling on machines with module-proxy access","Match installed Go toolchain to the go.mod go directive"],"tags":["go","go-mod","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"}