hyperledger/fabric · error
invalid input json. Contains duplicate record for {"namespa
Error message
invalid input json. Contains duplicate record for {"namespace":"%s","key":"%s"}. Aborting identifytxs What it means
generateRecordsMap keys records by (namespace, collection, key); a duplicate (namespace,key) pair in the input JSON makes the map ambiguous (later-height tracking would conflict), so it returns this error naming the duplicated namespace/key and aborts IdentifyTxs.
Source
Thrown at internal/ledgerutil/identifytxs/identifytxs.go:200
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 "+
" {\"namespace\":\"%s\",\"key\":\"%s\"}. Aborting identifytxs", r.Namespace, r.Key)
}
// New entry, add entry and height
blockNum, txNum := r.GetLaterHeight()
// Only namespace and key were provided, record doesn't contain height. Set to "infinite" height to iterate entire block store.
if blockNum == 0 && txNum == 0 {
blockNum = math.MaxUint64
txNum = math.MaxUint64
}
// Check for max height
if blockNum > maxBlock || (blockNum == maxBlock && txNum > maxTx) {
maxBlock = blockNum
maxTx = txNum
}
// Create output file writer
filename := fmt.Sprintf("txlist%d.json", i+1)
ofw, err := jsonrw.NewJSONFileWriter(filepath.Join(outputDirPath, filename))
if err != nil {View on GitHub (pinned to 2736b63f8f)
Solutions
- Remove duplicate entries with the same namespace/key from the JSON, keeping the one with the latest height if applicable
- Regenerate a single diff record list from one compare run instead of merging files
- Preprocess with a script that dedupes on (namespace, collection, key) before invoking identifytxs
Example fix
// before
[{"namespace":"ns","key":"k1"},{"namespace":"ns","key":"k1"}]
// after
[{"namespace":"ns","key":"k1"}] Defensive patterns
Strategy: validation
Validate before calling
// Go: dedupe records on namespace/collection/key before calling IdentifyTxs
seen := map[string]bool{}
var out []models.DiffRecord
for _, r := range records.DiffRecords {
k := r.Namespace + "|" + r.Key
if seen[k] { continue }
seen[k] = true
out = append(out, r)
} Try / catch
if _, _, err := ledgerutil.IdentifyTxs(recPath, outDir); err != nil {
if strings.Contains(err.Error(), "duplicate record") {
return fmt.Errorf("dedupe namespace/key pairs in the diff JSON: %w", err)
}
return err
} Prevention
- Never concatenate diff JSONs from multiple compare runs
- Preprocess inputs to dedupe on (namespace, collection, key)
- Use one authoritative compare output per identifytxs run
When it happens
Trigger: Running ledgerutil identifytxs with a diff record list that contains two records with the same namespace and key (collection differing may still collide when both are unhashed/empty).
Common situations: Manually merging or concatenating two diff JSON outputs; duplicates introduced while editing the file; combining records from multiple compare runs into one list.
Related errors
- no records were read. JSON record list is either empty or no
- invalid input json. Each record entry must contain both a "n
- %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/9312a00b1b4bf33c.
Report an issue: GitHub.