hyperledger/fabric · warning
options --raw (-r) and --hex (-x) are not compatible
Error message
options --raw (-r) and --hex (-x) are not compatible
What it means
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.
Source
Thrown at internal/peer/chaincode/common.go:133
}
ca, err := protoutil.UnmarshalChaincodeAction(pRespPayload.Extension)
if err != nil {
return errors.WithMessage(err, "error while unmarshalling chaincode action")
}
if proposalResp.Endorsement == nil {
return errors.Errorf("endorsement failure during invoke. response: %v", proposalResp.Response)
}
logger.Infof("Chaincode invoke successful. result: %v", ca.Response)
} else {
if proposalResp == nil {
return errors.New("error during query: received nil proposal response")
}
if proposalResp.Endorsement == nil {
return errors.Errorf("endorsement failure during query. response: %v", proposalResp.Response)
}
if chaincodeQueryRaw && chaincodeQueryHex {
return fmt.Errorf("options --raw (-r) and --hex (-x) are not compatible")
}
if chaincodeQueryRaw {
fmt.Println(proposalResp.Response.Payload)
return nil
}
if chaincodeQueryHex {
fmt.Printf("%x\n", proposalResp.Response.Payload)
return nil
}
fmt.Println(string(proposalResp.Response.Payload))
}
return nil
}
type endorsementPolicy struct {
ChannelConfigPolicy string `json:"channelConfigPolicy,omitempty"`
SignaturePolicy string `json:"signaturePolicy,omitempty"`
}View on GitHub (pinned to 2736b63f8f)
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
Example fix
// before
peer chaincode query -C mychannel -n mycc -c '{"Args":["get","a"]}' -r -x
// after
peer chaincode query -C mychannel -n mycc -c '{"Args":["get","a"]}' -x Defensive patterns
Strategy: validation
Validate before calling
raw = args.includes('-r') or args.includes('--raw')
hex = args.includes('-x') or args.includes('--hex')
if raw and hex:
raise SystemExit('--raw and --hex are mutually exclusive') Prevention
- 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
When it happens
Trigger: peer chaincode query invoked with both -r and -x flags set at the same time.
Common situations: Script defaults that each add one flag; copy-pasted command lines combining examples; wrapper scripts appending both options unconditionally.
Related errors
- cannot specify both "--signature-policy" and "--channel-conf
- must supply value for %s name parameter
- error parsing transient string
- The required parameter 'channelID' is empty. Rerun the comma
- The required parameter 'channelID' is empty. Rerun the comma
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/20c8b7157987b981.
Report an issue: GitHub.