{"record":{"id":"dc4add0c67a0e18e","repo":"hyperledger/fabric","slug":"empty-json-chaincode-parameters-must-contain-the-f","errorCode":null,"errorMessage":"empty JSON chaincode parameters must contain the following keys: 'Args' or 'Function' and 'Args'","messagePattern":"empty JSON chaincode parameters must contain the following keys: 'Args' or 'Function' and 'Args'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/peer/chaincode/common.go","lineNumber":306,"sourceCode":"\t// Generic JSON with interface{}\n\tif chaincodeCtorJSON != \"{}\" {\n\t\tvar f any\n\t\terr := json.Unmarshal([]byte(chaincodeCtorJSON), &f)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"chaincode argument error\")\n\t\t}\n\t\tm := f.(map[string]any)\n\t\tsm := make(map[string]any)\n\t\tfor k := range m {\n\t\t\tsm[strings.ToLower(k)] = m[k]\n\t\t}\n\t\t_, argsPresent := sm[\"args\"]\n\t\t_, funcPresent := sm[\"function\"]\n\t\tif !argsPresent || (len(m) == 2 && !funcPresent) || len(m) > 2 {\n\t\t\treturn errors.New(\"non-empty JSON chaincode parameters must contain the following keys: 'Args' or 'Function' and 'Args'\")\n\t\t}\n\t} else {\n\t\treturn errors.New(\"empty JSON chaincode parameters must contain the following keys: 'Args' or 'Function' and 'Args'\")\n\t}\n\n\treturn nil\n}\n\nfunc validatePeerConnectionParameters(cmdName string) error {\n\tif connectionProfile != common.UndefinedParamValue {\n\t\tnetworkConfig, err := common.GetConfig(connectionProfile)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif len(networkConfig.Channels[channelID].Peers) != 0 {\n\t\t\tpeerAddresses = []string{}\n\t\t\ttlsRootCertFiles = []string{}\n\t\t\tfor peer, peerChannelConfig := range networkConfig.Channels[channelID].Peers {\n\t\t\t\tif peerChannelConfig.EndorsingPeer {\n\t\t\t\t\tpeerConfig, ok := networkConfig.Peers[peer]\n\t\t\t\t\tif !ok {","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/internal/peer/chaincode/common.go#L288-L324","documentation":"This error is thrown by checkChaincodeCmdParams when the --ctor JSON string is empty or cannot be parsed into a non-empty map, i.e. the chaincode call parameters are missing entirely. The CLI requires constructor parameters to contain 'Args', or 'Function' and 'Args'. An empty payload gives the chaincode nothing to execute.","triggerScenarios":"Running a peer chaincode command with --ctor '' or omitting --ctor entirely, or passing a value that parses to an empty map (e.g. '{}' is empty JSON object yielding empty map).","commonSituations":"Forgetting the --ctor flag on invoke/query, shell quoting dropping the argument, scripts building the command with an empty variable, or migrating commands where the ctor was removed accidentally.","solutions":["Pass a valid ctor: --ctor '{\"Args\":[\"Init\"]}'","If the chaincode takes no arguments, still pass --ctor '{\"Args\":[]}'","Check shell quoting so the JSON isn't dropped: quote the whole argument","Verify the command variable in scripts isn't empty before exec"],"exampleFix":"// before\npeer chaincode invoke -C mychannel -n mycc --ctor ''\n// after\npeer chaincode invoke -C mychannel -n mycc --ctor '{\"Args\":[\"Init\",\"a\",\"1\",\"b\",\"2\"]}'","handlingStrategy":"validation","validationCode":"[ -n \"$CTOR\" ] && echo \"$CTOR\" | jq -e 'type == \"object\" and (has(\"Args\") or has(\"args\"))' >/dev/null || { echo 'ctor must be non-empty JSON with Args'; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never omit --ctor for invoke/query commands","For no-arg calls use {\"Args\":[]}","Quote ctor variables in shell: \"${CTOR}\"","Add a pre-flight check in scripts that CTOR is set and valid JSON"],"tags":["hyperledger-fabric","chaincode","cli","missing-argument"],"backgroundTag":"invalid-json-constructor-args","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"}