Git Product home page Git Product logo

Comments (7)

bestbeforetoday avatar bestbeforetoday commented on June 2, 2024

Are you saying that, when this error occurred, the getDetails() method on the exception returns an empty list? Apart from the updateNonExistentAsset() method in the asset-transfer-basic sample client application, the error details for any exceptions thrown are not explicitly extracted and printed as part of the error handling, since none of the other calls are expected to produce (and therefore do not need to demonstrate) failures.

from fabric.

gqqnbig avatar gqqnbig commented on June 2, 2024

I now understand the error message.

The text from evaluate.go and endorse.go asks developers to check the property Details. The ambiguity is from the word "attached" and the word "details".

The word "attached" is used for instance when we send emails, "see the attached file"; or refer to something above or below in a body of passages. When I read the following command line output, I can't realize "attached" refers to a property of an object in the programming language.

asset-transfer-basic/application-gateway-java main $ ./gradlew run

> Task :run

--> Submit Transaction: InitLedger, function creates the initial set of assets on the ledger
Exception in thread "main" org.hyperledger.fabric.client.EndorseException: io.grpc.StatusRuntimeException: ABORTED: failed to endorse transaction, see attached details for more info
        at org.hyperledger.fabric.client.GatewayClient.endorse(GatewayClient.java:73)
        at org.hyperledger.fabric.client.ProposalImpl.endorse(ProposalImpl.java:74)
        at org.hyperledger.fabric.client.Proposal.endorse(Proposal.java:65)
        at org.hyperledger.fabric.client.ContractImpl.submitTransaction(ContractImpl.java:38)
        at App.initLedger(App.java:143)
        at App.run(App.java:117)
        at App.main(App.java:71)

Then, for the word "details", can we make it upper case so that it looks like a proper noun? or revise it to "the property Details"? Otherwise it's hard for either end-users or developers to tell whether this English word "details" just means some information in general, or a very specific thing, the property or field named "details".

Given the analysis, I'd like to reword the string for clarity. I propose the following change

        if plan.completedLayout == nil {
-               return nil, newRpcError(codes.Aborted, "failed to collect enough transaction endorsements, see attached details for more info", plan.errorDetails...)
+               return nil, newRpcError(codes.Aborted, "failed to collect enough transaction endorsements, check Status.Details for more info", plan.errorDetails...)
        }

Are you OK with the change? If so, I can make a PR.

An even better and clearer solution is to write this in case errorDetails is empty. Up to you.

if plan.completedLayout == nil {
    errorMsg := "failed to collect enough transaction endorsements"
    if len(plan.errorDetails) > 0 {
        errorMsg += ", check Status.Details for more info"
    }
    return nil, newRpcError(codes.Aborted, errorMsg, plan.errorDetails...)
}

from fabric.

bestbeforetoday avatar bestbeforetoday commented on June 2, 2024

I think at the point those error are created there will always be some error details to associate with the gRPC error. Different errors are returned earlier in flow if it doesn't get far enough for any invocations to be attempted.

I am not sure how well the proposed message fits all the different client programming languages. I suspect sticking to more natural language is more appropriate. Documentation for the gRPC richer error model uses the term error details to describe these elements of the error response. We describe them as "gRPC error details" in the Java and Node API documentation. Maybe this kind of wording would work:

failed to collect enough transaction endorsements; see associated gRPC error details for more information

or

failed to collect enough transaction endorsements; see associated error details field for more information

What do you think?

I believe the intention of the wording is to help guide users to helpful information. If it actually causes more confusion than help, an option might be to just remove it and rely on documentation and samples for error handling.

At the client end, I wonder if we can do anything better to make sure error details are visible to human readers. For Node, logging the error to the console already prints the details since they are included as a property on the error object:

https://hyperledger-fabric.readthedocs.io/en/release-2.5/write_first_app.html#handle-transaction-errors

For Java , maybe we could override printStackTrace() to append the error details, similar to how the sample application does. For Go, I'm not sure there is a good solution as multi-line error message text seems to go against the idiom that error messages should generally be composable in the form, "msg1: msg2" when errors are wrapped.

from fabric.

gqqnbig avatar gqqnbig commented on June 2, 2024

Wow, I didn't expect you to submit a PR so fast. Personally I perfer your second option as it includes the word "field".

But since your PR has got merged, I will test it after I come back from my 10-day vacation. Thank you.

from fabric.

bestbeforetoday avatar bestbeforetoday commented on June 2, 2024

Just note that my PR above only changes the output of the Java printStacktrace() method (and its variants) for the Java Exceptions thrown by the client API. It will be included in the next release version of the API (>= v1.3.3). Before then, it is published and can be accessed as a snapshot from GitHub packages.

I think the Node client API implementation is already OK. I can't immediately think of a good (idiomatic) way to improve the Go implementation. Suggestions welcome.

I have not changed the Fabric error message. Feel free to raise a pull request for that.

from fabric.

denyeart avatar denyeart commented on June 2, 2024

I also agree that the latter text suggestion from @bestbeforetoday will clarify it.

Sounds like Node and Java will automatically log the details now, that's good and in my opinion required information for troubleshooting. For Go I would suggest to concatenate the N details with a colon as a delimiter. I think having the information in some form so that developers can troubleshoot is more important than following the idiomatic guidelines in this case.

from fabric.

gqqnbig avatar gqqnbig commented on June 2, 2024

I compiled the version that has your changes, and I'm so far happy with the outcome.

asset-transfer-basic/application-gateway-java main $ ./gradlew run

> Task :run

--> Submit Transaction: InitLedger, function creates the initial set of assets on the ledger
Successfully caught the error:
org.hyperledger.fabric.client.EndorseException: io.grpc.StatusRuntimeException: ABORTED: failed to endorse transaction, see attached details for more info
        at org.hyperledger.fabric.client.GatewayClient.endorse(GatewayClient.java:73)
        at org.hyperledger.fabric.client.ProposalImpl.endorse(ProposalImpl.java:74)
        at org.hyperledger.fabric.client.Proposal.endorse(Proposal.java:65)
        at org.hyperledger.fabric.client.ContractImpl.submitTransaction(ContractImpl.java:38)
        at App.initLedger(App.java:144)
        at App.run(App.java:117)
        at App.main(App.java:71)
Caused by: io.grpc.StatusRuntimeException: ABORTED: failed to endorse transaction, see attached details for more info
        at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:271)
        at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:252)
        at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:165)
        at org.hyperledger.fabric.protos.gateway.GatewayGrpc$GatewayBlockingStub.endorse(GatewayGrpc.java:472)
        at org.hyperledger.fabric.client.GatewayClient.endorse(GatewayClient.java:71)
        ... 6 more
Transaction ID: c3bfb74fb91941935a733c015e36f6f92b5813d2b88b7c3b1af2458a251fb784
Error Details:
- address: peer0.org1.example.com:7051, mspId: Org1MSP, message: chaincode response 500, Undefined contract called

--> Evaluate Transaction: GetAllAssets, function returns all the current assets on the ledger
Exception in thread "main" org.hyperledger.fabric.client.GatewayException: io.grpc.StatusRuntimeException: UNKNOWN: evaluate call to endorser returned error: chaincode response 500, Undefined contract called
...

The output now has the "Error Details" section that corresponds to the hint "see attached details for more info".

I'm gonna close this issue.

from fabric.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.