{"record":{"id":"e6559b5811c76cf2","repo":"hyperledger/fabric","slug":"chaincode-s-is-specified-as-not-containing-privat","errorCode":null,"errorMessage":"chaincode %s is specified as not containing private data reads but should be explicitly defined via a chaincode flag","messagePattern":"chaincode (.+?) is specified as not containing private data reads but should be explicitly defined via a chaincode flag","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"discovery/cmd/endorsers.go","lineNumber":181,"sourceCode":"\n\tif ec.NoPrivReads == nil {\n\t\tec.NoPrivReads = &emptyChaincodes\n\t}\n\n\tvar emptyCollections map[string]string\n\tif ec.Collections == nil {\n\t\tec.Collections = &emptyCollections\n\t}\n\n\tres := make(map[string][]string)\n\n\tfor _, cc := range *ec.Chaincodes {\n\t\tres[cc] = nil\n\t}\n\n\tfor _, cc := range *ec.NoPrivReads {\n\t\tif !ec.existsInChaincodes(cc) {\n\t\t\treturn nil, errors.Errorf(\"chaincode %s is specified as not containing private data reads but should be explicitly defined via a chaincode flag\", cc)\n\t\t}\n\t}\n\n\tfor cc, collections := range *ec.Collections {\n\t\tif !ec.existsInChaincodes(cc) {\n\t\t\treturn nil, errors.Errorf(\"a collection specified chaincode %s but it wasn't specified with a chaincode flag\", cc)\n\t\t}\n\t\tres[cc] = strings.Split(collections, \",\")\n\t}\n\n\treturn res, nil\n}\n\nfunc parseEndorsementDescriptors(descriptors []*discovery.EndorsementDescriptor) []endorsermentDescriptor {\n\tvar res []endorsermentDescriptor\n\tfor _, desc := range descriptors {\n\t\tendorsersByGroups := make(map[string][]endorser)\n\t\tfor grp, endorsers := range desc.EndorsersByGroups {","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/discovery/cmd/endorsers.go#L163-L199","documentation":"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.","triggerScenarios":"Running `discover endorsers` with --chaincode for one chaincode but listing another chaincode in --noPrivateReads, or passing --noPrivateReads cc1 while forgetting --chaincode cc1 entirely.","commonSituations":"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.","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"],"exampleFix":"// before\ndiscover --configFile conf.yaml endorsers --server peer:7051 --chaincode cc1 --noPrivateReads cc2\n\n// after\ndiscover --configFile conf.yaml endorsers --server peer:7051 --chaincode cc1 --chaincode cc2 --noPrivateReads cc2","handlingStrategy":"validation","validationCode":"const chaincodes = flags.chaincode || [];\nconst noPrivReads = flags.noPrivateReads || [];\nconst missing = noPrivReads.filter(cc => !chaincodes.includes(cc));\nif (missing.length > 0) {\n  throw new Error(`--noPrivateReads entries not in --chaincode: ${missing.join(',')}`);\n}","typeGuard":"function hasAllNoPrivReadsDefined(chaincodes, noPrivReads) {\n  return noPrivReads.every(cc => chaincodes.includes(cc));\n}","tryCatchPattern":"try {\n  resp, err := runDiscover(args)\n  if err != nil { log.Fatalf(\"input validation: %v\", err) }\n} catch (e) {\n  if (String(e.message).includes('explicitly defined via a chaincode flag')) {\n    console.error('Sync --chaincode and --noPrivateReads lists');\n  }\n}","preventionTips":["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"],"tags":["cli","configuration","discovery","input-validation"],"backgroundTag":"chaincode-flag-mismatch","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"}