{"record":{"id":"b7b9c9e7c4593fc8","repo":"hyperledger/fabric","slug":"with-s","errorCode":null,"errorMessage":" with: %s","messagePattern":" with: %s","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"core/chaincode/platforms/golang/list.go","lineNumber":98,"sourceCode":"\t\tif packageInfo.Incomplete {\n\t\t\treturn nil, fmt.Errorf(\"failed to calculate dependencies: incomplete package: %s\", packageInfo.ImportPath)\n\t\t}\n\t\tif !packageInfo.Goroot {\n\t\t\tlist = append(list, packageInfo)\n\t\t}\n\t}\n\n\terr = cmd.Wait()\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"listing deps for package %s failed\", pkg)\n\t}\n\n\treturn list, nil\n}\n\nfunc wrapExitErr(err error, message string) error {\n\tif ee, ok := err.(*exec.ExitError); ok {\n\t\treturn errors.Wrapf(err, message+\" with: %s\", strings.TrimRight(string(ee.Stderr), \"\\n\\r\\t\"))\n\t}\n\treturn errors.Wrap(err, message)\n}\n\ntype ModuleInfo struct {\n\tDir        string\n\tGoMod      string\n\tImportPath string\n\tModulePath string\n}\n\n// listModuleInfo extracts module information for the curent working directory.\nfunc listModuleInfo(extraEnv ...string) (*ModuleInfo, error) {\n\tctx, cancel := context.WithTimeout(context.Background(), listTimeout)\n\tdefer cancel()\n\n\tcmd := exec.CommandContext(ctx, \"go\", \"list\", \"-json\", \".\")\n\tcmd.Env = append(os.Environ(), extraEnv...)","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/platforms/golang/list.go#L80-L116","documentation":"wrapExitErr appends the captured stderr of a failed exec.Command (' with: %s') to the wrapped error. It is not itself a distinct failure — the trailing 'with: <stderr>' text carries the actual reason (usually go tool output) that the command exited non-zero.","triggerScenarios":"Any go tool invocation (gopathDependencyPackageInfo, listModuleInfo, describeGopath, moduleInfo) exits with *exec.ExitError; wrapExitErr decorates it with the trimmed stderr so the message reads '<message>: <err> with: <go stderr>'.","commonSituations":"Go compile/import errors surfaced in stderr; 'go: cannot find main module'; missing go binary arguments; malformed package patterns passed to go list.","solutions":["Read everything after 'with:' — it contains the authoritative go error","Fix the root cause reported there (module resolution, compile error, bad pattern)","Re-run the equivalent go command locally in the chaincode dir to reproduce and iterate","If stderr is empty, check the wrapped exit status for signal/OOM kills"],"exampleFix":"// interpreting\nlisting deps for package src/chcc failed: exit status 1 with: go: cannot find main module\n// fix: add go.mod or set GO111MODULE=off for GOPATH builds","handlingStrategy":"try-catch","validationCode":"// run the underlying tool first\ncmd := exec.Command(\"go\", \"list\", \"-m\", \"-json\")\nvar stderr bytes.Buffer\ncmd.Stderr = &stderr\nif err := cmd.Run(); err != nil { return fmt.Errorf(\"go failed: %v: %s\", err, stderr.String()) }","typeGuard":"func stderrOf(err error) string { var ee *exec.ExitError; if errors.As(err, &ee) { return strings.TrimSpace(string(ee.Stderr)) }; return \"\" }","tryCatchPattern":"_, err := platform.GetDeploymentPayload(path)\nif err != nil {\n  if i := strings.Index(err.Error(), \" with: \"); i >= 0 { log.Print(\"go stderr:\", err.Error()[i+6:]) }\n}","preventionTips":["Always read the text after 'with:' for root cause","Reproduce with the same go command locally","Keep go toolchain output clean (no wrappers)"],"tags":["golang","exec","stderr","fabric"],"backgroundTag":"exec-exit-error","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}