hyperledger/fabric · error
chaincode %s is specified as not containing private data rea
Error message
chaincode %s is specified as not containing private data reads but should be explicitly defined via a chaincode flag
What it means
The discovery CLI's parseInput validates that every chaincode named in the --noPrivateReads flag is also listed in the chaincode selection. Discovery needs to know which chaincodes to build endorsement descriptors for, and the no-priv-reads hint only makes sense for a chaincode that is actually being queried. If a chaincode appears in NoPrivReads but not in Chaincodes, input is inconsistent and parsing aborts.
Source
Thrown at discovery/cmd/endorsers.go:181
if ec.NoPrivReads == nil {
ec.NoPrivReads = &emptyChaincodes
}
var emptyCollections map[string]string
if ec.Collections == nil {
ec.Collections = &emptyCollections
}
res := make(map[string][]string)
for _, cc := range *ec.Chaincodes {
res[cc] = nil
}
for _, cc := range *ec.NoPrivReads {
if !ec.existsInChaincodes(cc) {
return nil, errors.Errorf("chaincode %s is specified as not containing private data reads but should be explicitly defined via a chaincode flag", cc)
}
}
for cc, collections := range *ec.Collections {
if !ec.existsInChaincodes(cc) {
return nil, errors.Errorf("a collection specified chaincode %s but it wasn't specified with a chaincode flag", cc)
}
res[cc] = strings.Split(collections, ",")
}
return res, nil
}
func parseEndorsementDescriptors(descriptors []*discovery.EndorsementDescriptor) []endorsermentDescriptor {
var res []endorsermentDescriptor
for _, desc := range descriptors {
endorsersByGroups := make(map[string][]endorser)
for grp, endorsers := range desc.EndorsersByGroups {View on GitHub (pinned to 2736b63f8f)
Solutions
- Add the missing chaincode to the --chaincode flag so it is explicitly defined
- Remove the extraneous entry from --noPrivateReads if that chaincode should not be queried
- Fix typos so the chaincode name matches exactly in both flags
Example fix
// before discover --configFile conf.yaml endorsers --server peer:7051 --chaincode cc1 --noPrivateReads cc2 // after discover --configFile conf.yaml endorsers --server peer:7051 --chaincode cc1 --chaincode cc2 --noPrivateReads cc2
Defensive patterns
Strategy: validation
Validate before calling
const chaincodes = flags.chaincode || [];
const noPrivReads = flags.noPrivateReads || [];
const missing = noPrivReads.filter(cc => !chaincodes.includes(cc));
if (missing.length > 0) {
throw new Error(`--noPrivateReads entries not in --chaincode: ${missing.join(',')}`);
} Type guard
function hasAllNoPrivReadsDefined(chaincodes, noPrivReads) {
return noPrivReads.every(cc => chaincodes.includes(cc));
} Try / catch
try {
resp, err := runDiscover(args)
if err != nil { log.Fatalf("input validation: %v", err) }
} catch (e) {
if (String(e.message).includes('explicitly defined via a chaincode flag')) {
console.error('Sync --chaincode and --noPrivateReads lists');
}
} Prevention
- Generate both --chaincode and --noPrivateReads from a single list variable
- Validate flag overlap in wrapper scripts before invoking discover
- Grep CI scripts for noPrivateReads entries missing from chaincode flags
When it happens
Trigger: Running `discover endorsers` with --chaincode for one chaincode but listing another chaincode in --noPrivateReads, or passing --noPrivateReads cc1 while forgetting --chaincode cc1 entirely.
Common situations: Copy-pasted CLI commands where the --chaincode flag list was edited but the --noPrivateReads list was not; scripts generating flags from separate lists that drift out of sync; typos in the chaincode name between the two flags.
Related errors
- a collection specified chaincode %s but it wasn't specified
- no server specified
- failed getting local MSP principal during channelless check
- invocation chain should not be empty
- chaincode name should not be empty
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/e6559b5811c76cf2.
Report an issue: GitHub.