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

Inconsistent debug Field Type in Error Details After connect-go v1.15.0 Update #1095

Closed
wangyuehong opened this issue Jun 1, 2024 · 2 comments · Fixed by #1221
Closed

Inconsistent debug Field Type in Error Details After connect-go v1.15.0 Update #1095

wangyuehong opened this issue Jun 1, 2024 · 2 comments · Fixed by #1221
Labels
bug Something isn't working

Comments

@wangyuehong
Copy link

Describe the bug

After connectrpc/connect-go#688 was merged into connect-go, the debug field in error details is not consistently an object but can be any JSON type.

Error JSON produced by connect-go v1.14.0 and earlier:

{
    "code": "invalid_argument",
    "message": "bad sentence: xxx",
    "details": [
        {
            "type": "google.protobuf.StringValue",
            "value": "Cg5zZXJ2ZXIgZGV0YWlscw",
            "debug": {
                "@type": "type.googleapis.com/google.protobuf.StringValue",
                "value": "server details"
            }
        }
    ]
}

The same error JSON from connect-go v1.15.0:

{
    "code": "invalid_argument",
    "message": "bad sentence: xxx",
    "details": [
        {
            "type": "google.protobuf.StringValue",
            "value": "Cg5zZXJ2ZXIgZGV0YWlscw",
            "debug": "server details"
        }
    ]
}

The current code in connect-es expects the debug field to be an object, so the new error JSON format cannot be handled after connect-go v1.15.0.

("debug" in detail && typeof detail.debug != "object")

To Reproduce
Return the following error in a connect-go server:

err := connect.NewError(connect.CodeInvalidArgument, fmt.Errorf("bad sentence: %s", "xxx"))
errDetail, _ := connect.NewErrorDetail(&wrapperspb.StringValue{Value: "server details"})
err.AddDetail(errDetail)

Expected error:

ConnectError: [invalid_argument] bad sentence: xxx

Actual error:

ConnectError: [invalid_argument] HTTP 400

Environment (please complete the following information):

  • @connectrpc/connect-web version: 1.4.0
  • connect-go version: v1.5.0 and later.

Additional context
This code might fix the issue, but I am not familiar with TypeScript, so I am just reporting it:

         typeof detail.type != "string" ||
-        typeof detail.value != "string" ||
-        ("debug" in detail && typeof detail.debug != "object")
+        typeof detail.value != "string"
       ) {
@wangyuehong wangyuehong added the bug Something isn't working label Jun 1, 2024
@srikrsna-buf
Copy link
Member

Thank you for the detailed report. @jhump should this be added to conformance suite?

@jhump
Copy link
Member

jhump commented Jun 4, 2024

@jhump should this be added to conformance suite?

That's probably a good idea. The well-known types seem to always be causing problems :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants