{"record":{"id":"12448d57f5eb7fec","repo":"hyperledger/fabric","slug":"failed-to-unmarshal-output-from-go-list","errorCode":null,"errorMessage":"failed to unmarshal output from 'go list'","messagePattern":"failed to unmarshal output from 'go list'","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/platforms/golang/list.go","lineNumber":133,"sourceCode":"\tcmd := exec.CommandContext(ctx, \"go\", \"list\", \"-json\", \".\")\n\tcmd.Env = append(os.Environ(), extraEnv...)\n\n\toutput, err := cmd.Output()\n\tif err != nil {\n\t\treturn nil, wrapExitErr(err, \"'go list' failed\")\n\t}\n\n\tvar moduleData struct {\n\t\tImportPath string\n\t\tModule     struct {\n\t\t\tDir   string\n\t\t\tPath  string\n\t\t\tGoMod string\n\t\t}\n\t}\n\n\tif err := json.Unmarshal(output, &moduleData); err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to unmarshal output from 'go list'\")\n\t}\n\n\treturn &ModuleInfo{\n\t\tDir:        moduleData.Module.Dir,\n\t\tGoMod:      moduleData.Module.GoMod,\n\t\tImportPath: moduleData.ImportPath,\n\t\tModulePath: moduleData.Module.Path,\n\t}, nil\n}\n","sourceCodeStart":115,"sourceCodeEnd":143,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/platforms/golang/list.go#L115-L143","documentation":"listModuleInfo runs 'go list -m -json' in module mode and json.Unmarshals its output; if the output is not valid JSON matching the expected shape, it wraps the failure with 'failed to unmarshal output from 'go list''. Indicates the go tool produced unexpected output.","triggerScenarios":"moduleInfo -> listModuleInfo: the 'go list' subprocess output cannot be unmarshalled into the anonymous struct {Dir, ImportPath, GoMod, Module{...}} — e.g. go printed warnings/human text to stdout, or an ancient/odd go version emitted different JSON.","commonSituations":"GOFLAGS injecting extra output; wrapper scripts around go polluting stdout; very old Go toolchain in builder image; locale/encoding output mixed into the stream.","solutions":["Check GOFLAGS and GOENV for settings that make go print extra output; unset them (GOFLAGS=)","Ensure the builder image's Go version is one supported by the fabric version","Run 'go list -m -json' manually in the chaincode dir to inspect raw output","Remove any go wrapper/shim scripts that prepend text to stdout"],"exampleFix":"// before\nGOFLAGS=\"-mod=vendor -x\"  (verbose output pollutes)\n// after\nGOFLAGS=\"-mod=vendor\"","handlingStrategy":"validation","validationCode":"out, err := exec.Command(\"go\", \"list\", \"-m\", \"-json\").Output()\nif err != nil { return err }\nif !json.Valid(out) { return fmt.Errorf(\"go list emitted non-JSON output: %s\", out) }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Unset GOFLAGS that add non-JSON output","Use a fabric-supported Go version in the builder","Do not wrap the go binary with scripts writing to stdout","Set LANG=C to avoid locale-induced output"],"tags":["golang","json","unmarshal","fabric"],"backgroundTag":"json-unmarshal-failed","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"}