{"record":{"id":"c7da4ab9b8d1df08","repo":"hyperledger/fabric","slug":"failed-to-marshal-dataformatinfo-v","errorCode":null,"errorMessage":"failed to marshal dataformatInfo [%#v]","messagePattern":"failed to marshal dataformatInfo \\[%#v\\]","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/ledger/kvledger/txmgmt/statedb/statecouchdb/couchdoc_conv.go","lineNumber":261,"sourceCode":"\t\terr = errors.Wrap(err, \"failed to unmarshal channel metadata\")\n\t\tlogger.Errorf(\"%+v\", err)\n\t\treturn nil, err\n\t}\n\treturn metadataDoc, nil\n}\n\ntype dataformatInfo struct {\n\tVersion string `json:\"Version\"`\n}\n\nfunc encodeDataformatInfo(dataFormatVersion string) (*couchDoc, error) {\n\tvar err error\n\tdataformatInfo := &dataformatInfo{\n\t\tVersion: dataFormatVersion,\n\t}\n\tdataformatInfoJSON, err := json.Marshal(dataformatInfo)\n\tif err != nil {\n\t\terr = errors.Wrapf(err, \"failed to marshal dataformatInfo [%#v]\", dataformatInfo)\n\t\tlogger.Errorf(\"%+v\", err)\n\t\treturn nil, err\n\t}\n\treturn &couchDoc{jsonValue: dataformatInfoJSON, attachments: nil}, nil\n}\n\nfunc decodeDataformatInfo(couchDoc *couchDoc) (string, error) {\n\tdataformatInfo := &dataformatInfo{}\n\tif err := json.Unmarshal(couchDoc.jsonValue, dataformatInfo); err != nil {\n\t\terr = errors.Wrapf(err, \"failed to unmarshal json [%#v] into dataformatInfo\", couchDoc.jsonValue)\n\t\tlogger.Errorf(\"%+v\", err)\n\t\treturn \"\", err\n\t}\n\treturn dataformatInfo.Version, nil\n}\n\nfunc validateValue(value []byte) error {\n\tisJSON, jsonVal := tryCastingToJSON(value)","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/ledger/kvledger/txmgmt/statedb/statecouchdb/couchdoc_conv.go#L243-L279","documentation":"encodeDataformatInfo marshals a dataformatInfo document holding the state database's data format version. If json.Marshal fails, the error is wrapped with 'failed to marshal dataformatInfo [%#v]'. In stock Fabric this cannot realistically fail since the struct holds a single string field.","triggerScenarios":"writeDataFormatVersion calls encodeDataformatInfo and json.Marshal errors while building the dataformatInfo couchDoc for the current dataFormatVersion constant.","commonSituations":"Custom builds where dataformatInfo acquired non-serializable fields; JSON library or dependency corruption.","solutions":["Check the logged wrapped cause to find the offending field","Ensure dataformatInfo contains only JSON-serializable fields such as the Version string","Rebuild the peer from unmodified Fabric sources and retry"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if _, err := json.Marshal(&dataformatInfo{Version: dataFormatVersion}); err != nil {\n    return fmt.Errorf(\"dataformatInfo not serializable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"doc, err := encodeDataformatInfo()\nif err != nil {\n    logger.Errorf(\"dataformatInfo encode failed: %+v\", err)\n    return nil, err\n}","preventionTips":["Keep dataformatInfo a simple string-field struct","Rebuild with unmodified Fabric dependencies"],"tags":["json","marshalling","data-format","fabric-ledger"],"backgroundTag":"json-marshalling-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"}