{"record":{"id":"003e6b702dec3fbb","repo":"hyperledger/fabric","slug":"error-unmarshalling-to-block-s","errorCode":null,"errorMessage":"error unmarshalling to block: %s","messagePattern":"error unmarshalling to block: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/configtxgen/main.go","lineNumber":89,"sourceCode":"\tlogger.Info(\"Writing new channel tx\")\n\terr = writeFile(outputChannelCreateTx, protoutil.MarshalOrPanic(configtx), 0o640)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error writing channel create tx: %s\", err)\n\t}\n\treturn nil\n}\n\nfunc doInspectBlock(inspectBlock string) error {\n\tlogger.Info(\"Inspecting block\")\n\tdata, err := os.ReadFile(inspectBlock)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not read block %s\", inspectBlock)\n\t}\n\n\tlogger.Info(\"Parsing genesis block\")\n\tblock, err := protoutil.UnmarshalBlock(data)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error unmarshalling to block: %s\", err)\n\t}\n\terr = protolator.DeepMarshalJSON(os.Stdout, block)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"malformed block contents: %s\", err)\n\t}\n\treturn nil\n}\n\nfunc doInspectChannelCreateTx(inspectChannelCreateTx string) error {\n\tlogger.Info(\"Inspecting transaction\")\n\tdata, err := os.ReadFile(inspectChannelCreateTx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not read channel create tx: %s\", err)\n\t}\n\n\tlogger.Info(\"Parsing transaction\")\n\tenv, err := protoutil.UnmarshalEnvelope(data)\n\tif err != nil {","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/cmd/configtxgen/main.go#L71-L107","documentation":"Returned by configtxgen's doInspectBlock when protoutil.UnmarshalBlock fails on the bytes read from the file passed to -inspectBlock. It fires when the file content is not a valid protobuf-encoded Fabric block (e.g. a JSON file, a channel-create tx instead of a block, a truncated/corrupt file), so the block cannot be decoded for JSON dumping.","triggerScenarios":"Thrown at cmd/configtxgen/main.go:89 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the file passed to -inspectBlock was produced by configtxgen -outputBlock (or is a raw block from the ledger), not a channel creation tx or JSON export","Inspect the file with `file`/`xxd` to confirm it is binary protobuf and not empty or truncated","Regenerate the block with configtxgen using the same profile and retry the inspection"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}