{"record":{"id":"20c8b7157987b981","repo":"hyperledger/fabric","slug":"options-raw-r-and-hex-x-are-not-compatib","errorCode":null,"errorMessage":"options --raw (-r) and --hex (-x) are not compatible","messagePattern":"options --raw \\(-r\\) and --hex \\(-x\\) are not compatible","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/peer/chaincode/common.go","lineNumber":133,"sourceCode":"\t\t}\n\t\tca, err := protoutil.UnmarshalChaincodeAction(pRespPayload.Extension)\n\t\tif err != nil {\n\t\t\treturn errors.WithMessage(err, \"error while unmarshalling chaincode action\")\n\t\t}\n\t\tif proposalResp.Endorsement == nil {\n\t\t\treturn errors.Errorf(\"endorsement failure during invoke. response: %v\", proposalResp.Response)\n\t\t}\n\t\tlogger.Infof(\"Chaincode invoke successful. result: %v\", ca.Response)\n\t} else {\n\t\tif proposalResp == nil {\n\t\t\treturn errors.New(\"error during query: received nil proposal response\")\n\t\t}\n\t\tif proposalResp.Endorsement == nil {\n\t\t\treturn errors.Errorf(\"endorsement failure during query. response: %v\", proposalResp.Response)\n\t\t}\n\n\t\tif chaincodeQueryRaw && chaincodeQueryHex {\n\t\t\treturn fmt.Errorf(\"options --raw (-r) and --hex (-x) are not compatible\")\n\t\t}\n\t\tif chaincodeQueryRaw {\n\t\t\tfmt.Println(proposalResp.Response.Payload)\n\t\t\treturn nil\n\t\t}\n\t\tif chaincodeQueryHex {\n\t\t\tfmt.Printf(\"%x\\n\", proposalResp.Response.Payload)\n\t\t\treturn nil\n\t\t}\n\t\tfmt.Println(string(proposalResp.Response.Payload))\n\t}\n\treturn nil\n}\n\ntype endorsementPolicy struct {\n\tChannelConfigPolicy string `json:\"channelConfigPolicy,omitempty\"`\n\tSignaturePolicy     string `json:\"signaturePolicy,omitempty\"`\n}","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/internal/peer/chaincode/common.go#L115-L151","documentation":"CLI argument validation in chaincodeInvokeOrQuery: the user passed both --raw (-r) and --hex (-x) flags for a query, which are mutually exclusive output-format options; the command refuses to run rather than guessing the encoding.","triggerScenarios":"peer chaincode query invoked with both -r and -x flags set at the same time.","commonSituations":"Script defaults that each add one flag; copy-pasted command lines combining examples; wrapper scripts appending both options unconditionally.","solutions":["Use only one of -r or -x (bare query prints the response payload as a string)","Review wrapper scripts so exactly one output mode is passed","Omit both flags for the default textual payload output"],"exampleFix":"// before\npeer chaincode query -C mychannel -n mycc -c '{\"Args\":[\"get\",\"a\"]}' -r -x\n// after\npeer chaincode query -C mychannel -n mycc -c '{\"Args\":[\"get\",\"a\"]}' -x","handlingStrategy":"validation","validationCode":"raw = args.includes('-r') or args.includes('--raw')\nhex = args.includes('-x') or args.includes('--hex')\nif raw and hex:\n    raise SystemExit('--raw and --hex are mutually exclusive')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build CLI wrappers that expose a single output-mode parameter","Default to no flag (plain output) unless a format is explicitly needed","Add mutual-exclusion checks in generated scripts","Review CI scripts that template peer CLI commands"],"tags":["cli","flags","fabric"],"backgroundTag":"conflicting-flags","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"}