Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

peer chaincode query cli error message formatting #4180

Closed
AQBKX opened this issue Apr 25, 2023 · 6 comments · May be fixed by #4237
Closed

peer chaincode query cli error message formatting #4180

AQBKX opened this issue Apr 25, 2023 · 6 comments · May be fixed by #4237
Assignees
Labels
bug good first issue Good for newcomers

Comments

@AQBKX
Copy link

AQBKX commented Apr 25, 2023

Description

It seems like the error message returned from the chaincode is encoded and cannot be displayed correctly in Chinese when running the peer's command. The error message looks correct in the server-debug log but when querying through the peer, it returns a decoding error.

The problem could be with the way the error message is presented in the CLI invocation. The line generating the error message could be the cause of the issue, which is located at

return errors.Errorf("endorsement failure during invoke. response: %v", proposalResp.Response)
.

One possible solution to this problem is to use proto.MarshalTextString to insert the protocol buffer response message into the error string. More information about using proto.MarshalTextString can be found at https://pkg.go.dev/github.com/golang/protobuf@v1.5.3/proto#MarshalTextString.

Steps to reproduce

follow the docs to this,
https://github.com/hyperledger/fabric-samples/blob/main/full-stack-asset-transfer-guide/docs/SmartContractDev/01-Exercise-Getting-Started.md?plain=1#L316
and modify the string into 抱歉,资产 ${id} 尚未创建 in https://github.com/hyperledger/fabric-samples/blob/main/full-stack-asset-transfer-guide/contracts/asset-transfer-typescript/src/assetTransfer.ts#L54
then can see in sever-debug log

2023-04-24T15:51:36.498Z error [c-api:contracts-spi/chaincodefromcontract.js]     [mychannel-89d03efb] Error: 抱歉,资产 002 尚未创建  
2023-04-24T15:51:36.499Z error [c-api:lib/handler.js]                             [mychannel-89d03efb] Calling chaincode Invoke() returned error response [抱歉,资产 002 尚未创建]. Sending COMPLETED message back to peer  

and in org1admin log

peer chaincode query -C mychannel -n asset-transfer -c '{"Args":["ReadAsset","002"]}'
Error: endorsement failure during query. response: status:500 message:"\346\212\261\346\255\211\357\274\214\350\265\204\344\272\247 002 \345\260\232\346\234\252\345\210\233\345\273\272" 

the right message should be

peer chaincode query -C mychannel -n asset-transfer -c '{"Args":["ReadAsset","002"]}'
Error: endorsement failure during query. response: status:500 message:"抱歉,资产 002 尚未创建" 
@AQBKX AQBKX added the bug label Apr 25, 2023
@denyeart
Copy link
Contributor

The call to proto.MarshalTextString() sounds like an appropriate resolution. A pull request would be welcome.

@denyeart denyeart added the good first issue Good for newcomers label Apr 25, 2023
@AKARSHITJOSHI
Copy link

Hi @AQBKX I would like to contribute on this. Let me know if I can start.

@AQBKX
Copy link
Author

AQBKX commented Apr 28, 2023

hello, first clone https://github.com/hyperledger/fabric-samples/blob/main/full-stack-asset-transfer-guide , and follow docs/SmartContractDev , you will soon watch it, just in doc01 line 316, where error emerges.

@neonbhai
Copy link

Hi! I would like to work on this.

@denyeart
Copy link
Contributor

Thanks @neonbhai , I've assigned to you!

@rawatsushil
Copy link

Hi
is this still open ? I would like to start on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants