{"record":{"id":"f2cbb3aecf39a447","repo":"hyperledger/fabric","slug":"error-encoding-output","errorCode":null,"errorMessage":"error encoding output","messagePattern":"error encoding output","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/configtxlator/main.go","lineNumber":187,"sourceCode":"\n\tif msgType == nil {\n\t\treturn errors.Errorf(\"message of type %s unknown\", msgType)\n\t}\n\tmsg := reflect.New(msgType.Elem()).Interface().(proto.Message)\n\n\tin, err := io.ReadAll(input)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"error reading input\")\n\t}\n\n\terr = proto.Unmarshal(in, msg)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"error unmarshalling\")\n\t}\n\n\terr = protolator.DeepMarshalJSON(output, msg)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"error encoding output\")\n\t}\n\n\treturn nil\n}\n\nfunc computeUpdt(original, updated, output *os.File, channelID string) error {\n\torigIn, err := io.ReadAll(original)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"error reading original config\")\n\t}\n\n\torigConf := &cb.Config{}\n\terr = proto.Unmarshal(origIn, origConf)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"error unmarshalling original config\")\n\t}\n\n\tupdtIn, err := io.ReadAll(updated)","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/cmd/configtxlator/main.go#L169-L205","documentation":"protolator.DeepMarshalJSON failed while writing the decoded proto as JSON to the --output file. This wraps either a JSON marshaling error inside protolator or an underlying write error on the output file.","triggerScenarios":"Output file not writable (permissions, read-only mount, disk full), or protolator failing to convert an unusual/unknown field of the message to JSON.","commonSituations":"Writing to a container path mounted read-only, output directory missing, or custom proto extensions that protolator cannot represent.","solutions":["Check output path is writable and its directory exists","Re-run to a local temp file then move it into place","Verify the message type contains only fields protolator supports (stock fabric-protos types)","Check available disk space"],"exampleFix":"// before\nconfigtxlator decode --input config.pb --output /readonly/config.json --type common.Config\n// after\nconfigtxlator decode --input config.pb --output /tmp/config.json --type common.Config && mv /tmp/config.json /readonly/config.json","handlingStrategy":"try-catch","validationCode":"if [ ! -w \"$(dirname \"$OUTPUT\")\" ]; then echo \"output dir not writable\" >&2; exit 1; fi","typeGuard":null,"tryCatchPattern":"out, err := cmd.CombinedOutput()\nif err != nil && strings.Contains(string(out), \"error encoding output\") {\n    // write to temp file, then move\n}","preventionTips":["Write output to a writable temp location then mv","Check disk space and mount flags (not ro:)","Use stock fabric-protos message types"],"tags":["json","io","configtxlator","fabric","protobuf"],"backgroundTag":"file-write-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"}