hyperledger/fabric · error
invalid input json. Each record entry must contain both a "n
Error message
invalid input json. Each record entry must contain both a "namespace" and a "key" field. Aborting identifytxs
What it means
generateRecordsMap builds an internal key map from the diff records and requires every entry to carry both a namespace and a key. Any record missing either field makes the record set unusable, so it returns this error and IdentifyTxs aborts.
Source
Thrown at internal/ledgerutil/identifytxs/identifytxs.go:182
type compKeyMapWrapper struct {
compKeyMap compKeyMap
maxBlockNum uint64
maxTxNum uint64
}
// Generates an efficient data structure for checking records during block store traversal
// and for storing output file writers
// Returns generated compKeyMap and highest record height in a compKeyMapWrapper
func generateRecordsMap(records []*models.DiffRecord, outputDirPath string) (ckmw *compKeyMapWrapper, err error) {
// Reorganize records as hashmap for faster lookups
inputKeyMap := make(compKeyMap)
maxBlock := uint64(0)
maxTx := uint64(0)
for i, r := range records {
// Confirm all records have at least namespace and key
if r.Namespace == "" || r.Key == "" {
return nil, errors.Errorf("invalid input json. Each record entry must contain both " +
"a \"namespace\" and a \"key\" field. Aborting identifytxs")
}
// Check for hashed data
var ns, coll string
if r.Hashed {
ns, coll, err = decodeHashedNs(r.Namespace)
if err != nil {
return nil, err
}
} else {
ns = r.Namespace
}
// Record to compKey
ck := compKey{namespace: ns, collection: coll, key: r.Key}
// Check for duplicate entry
_, exists := inputKeyMap[ck]
if exists {
return nil, errors.Errorf("invalid input json. Contains duplicate record for "+View on GitHub (pinned to 2736b63f8f)
Solutions
- Inspect the JSON (entry index i reported by iteration order) and add/fill the missing namespace or key field on the offending record
- Regenerate the record list with ledgerutil compare instead of hand-editing
- Validate the JSON against the DiffRecordList schema (namespace, key, hashed, records) before running
Example fix
// before
{ "namespace": "", "key": "key1", "hashed": false }
// after
{ "namespace": "lscc", "key": "mycc", "hashed": false } Defensive patterns
Strategy: validation
Validate before calling
// Go: validate each record has namespace and key before calling IdentifyTxs
for i, r := range records.DiffRecords {
if r.Namespace == "" || r.Key == "" {
return fmt.Errorf("record %d missing namespace or key", i)
}
} Type guard
func validRecord(r models.DiffRecord) bool { return r.Namespace != "" && r.Key != "" } Try / catch
if _, _, err := ledgerutil.IdentifyTxs(recPath, outDir); err != nil {
if strings.Contains(err.Error(), "invalid input json") {
return fmt.Errorf("fix the record entries in the diff JSON: %w", err)
}
return err
} Prevention
- Schema-validate the diff JSON before running offline tools
- Avoid hand-editing compare output; regenerate it instead
- Keep records in the original DiffRecordList format
When it happens
Trigger: Running ledgerutil identifytxs with a JSON diff record list where at least one entry has an empty or missing "namespace" or "key" field.
Common situations: Hand-crafted or tool-modified JSON with a malformed entry; truncated file; schema drift after using output from an older ledgerutil version as input elsewhere.
Related errors
- no records were read. JSON record list is either empty or no
- invalid input json. Contains duplicate record for {"namespa
- %s already exists in %s. Choose a different location or remo
- BlockStore for %s does not exist. Aborting identifytxs
- malformed org definition for org: %s
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/88cd63e80c2069e6.
Report an issue: GitHub.