{"record":{"id":"905ed502e49f698a","repo":"hyperledger/fabric","slug":"error-marshalling-json-data","errorCode":null,"errorMessage":"error marshalling json data","messagePattern":"error marshalling json data","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/ledger/kvledger/txmgmt/statedb/statecouchdb/couchdb.go","lineNumber":1339,"sourceCode":"\t}\n\n\tqueryParms := batchRetrieveURL.Query()\n\n\t// While BatchRetrieveDocumentMetadata() does not return the entire document,\n\t// for reads/writes, we do need to get document so that we can get the ledger version of the key.\n\t// TODO For blind writes we do not need to get the version, therefore when we bulk get\n\t// the revision numbers for the write keys that were not represented in read set\n\t// (the second time BatchRetrieveDocumentMetadata is called during block processing),\n\t// we could set include_docs to false to optimize the response.\n\tqueryParms.Add(\"include_docs\", \"true\")\n\n\tkeymap := make(map[string]any)\n\n\tkeymap[\"keys\"] = keys\n\n\tjsonKeys, err := json.Marshal(keymap)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"error marshalling json data\")\n\t}\n\n\t// get the number of retries\n\tmaxRetries := dbclient.couchInstance.conf.MaxRetries\n\n\tresp, _, err := dbclient.handleRequest(http.MethodPost, \"BatchRetrieveDocumentMetadata\", batchRetrieveURL, jsonKeys, \"\", \"\", maxRetries, true, &queryParms, \"_all_docs\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer closeResponseBody(resp)\n\n\tif couchdbLogger.IsEnabledFor(zapcore.DebugLevel) {\n\t\tdump, _ := httputil.DumpResponse(resp, false)\n\t\t// compact debug log by replacing carriage return / line feed with dashes to separate http headers\n\t\tcouchdbLogger.Debugf(\"[%s] HTTP Response: %s\", dbclient.dbName, bytes.Replace(dump, []byte{0x0d, 0x0a}, []byte{0x20, 0x7c, 0x20}, -1))\n\t}\n\n\t// handle as JSON document","sourceCodeStart":1321,"sourceCodeEnd":1357,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/ledger/kvledger/txmgmt/statedb/statecouchdb/couchdb.go#L1321-L1357","documentation":"Returned by the CouchDB client when json.Marshal fails while encoding the bulk-get request body (the keymap of document IDs/revisions). Request serialization for batch document retrieval failed before any HTTP call was made.","triggerScenarios":"Thrown at core/ledger/kvledger/txmgmt/statedb/statecouchdb/couchdb.go:1339 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped marshal error for unsupported key types","Report/fix the internal data structure passed to the marshaller"],"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"}