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

Add tests for connect error detail debug data #921

Merged
merged 6 commits into from
Sep 11, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,73 @@ testCases:
error:
code: CODE_OUT_OF_RANGE
message: oops
- request:
# Clients must not depend on data in the "debug" key when deserializing details.
testName: error/disregard-detail-debug
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the test cases are typically named in a way that describe the scenario, vs describing the implementation's expected behavior. How about invalid-details-debug instead of disregard-detail-debug? (Sorry I didn't mention this with previous remark.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 There are a couple of existing tests named "allow-unrecognized...". Doesn't seem worth renaming them, but renamed the new ones in 7a9e8c2.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thanks for calling those out. I can sort those out in a separate PR.

service: connectrpc.conformance.v1.ConformanceService
method: Unary
streamType: STREAM_TYPE_UNARY
requestMessages:
- "@type": type.googleapis.com/connectrpc.conformance.v1.UnaryRequest
responseDefinition:
rawResponse:
statusCode: 422
headers:
- name: content-type
value: [ "application/json" ]
unary:
text: |
{
"code": "out_of_range",
"message": "oops",
"details": [
{
"type": "google.protobuf.FileDescriptorProto",
"value": "Cgp0ZXN0LnByb3Rv",
"debug": "garbage"
}
]
}
expectedResponse:
error:
code: CODE_OUT_OF_RANGE
message: oops
details:
- "@type": type.googleapis.com/google.protobuf.FileDescriptorProto
name: "test.proto"
- request:
# Clients must not depend on data in the "debug" key when deserializing details.
testName: error/missing-detail-debug
service: connectrpc.conformance.v1.ConformanceService
method: Unary
streamType: STREAM_TYPE_UNARY
requestMessages:
- "@type": type.googleapis.com/connectrpc.conformance.v1.UnaryRequest
responseDefinition:
rawResponse:
statusCode: 422
headers:
- name: content-type
value: [ "application/json" ]
unary:
text: |
{
"code": "out_of_range",
"message": "oops",
"details": [
{
"type": "google.protobuf.FileDescriptorProto",
"value": "Cgp0ZXN0LnByb3Rv"
}
]
}
expectedResponse:
error:
code: CODE_OUT_OF_RANGE
message: oops
details:
- "@type": type.googleapis.com/google.protobuf.FileDescriptorProto
name: "test.proto"
# # TODO: We can't actually represent an unrecognized detail in the YAML format, because
# # we use google.protobuf.Any, which requires the schema to represent in JSON or YAML 😭
# - request:
Expand Down Expand Up @@ -313,3 +380,80 @@ testCases:
details:
- "@type": type.googleapis.com/google.protobuf.FileDescriptorProto
name: "test.proto"
- request:
# Clients must not depend on data in the "debug" key when deserializing details.
testName: end-stream/disregard-detail-debug
service: connectrpc.conformance.v1.ConformanceService
method: ServerStream
streamType: STREAM_TYPE_SERVER_STREAM
requestMessages:
- "@type": type.googleapis.com/connectrpc.conformance.v1.ServerStreamRequest
responseDefinition:
rawResponse:
statusCode: 200
headers:
- name: content-type
value: [ "application/connect+proto" ]
stream:
items:
- flags: 2
payload:
text: |
{
"error": {
"code": "out_of_range",
"message": "oops",
"details": [
{
"type": "google.protobuf.FileDescriptorProto",
"value": "Cgp0ZXN0LnByb3Rv",
"debug": "garbage"
}
]
}
}
expectedResponse:
error:
code: CODE_OUT_OF_RANGE
message: oops
details:
- "@type": type.googleapis.com/google.protobuf.FileDescriptorProto
name: "test.proto"
- request:
# Clients must not depend on data in the "debug" key when deserializing details.
testName: end-stream/missing-detail-debug
service: connectrpc.conformance.v1.ConformanceService
method: ServerStream
streamType: STREAM_TYPE_SERVER_STREAM
requestMessages:
- "@type": type.googleapis.com/connectrpc.conformance.v1.ServerStreamRequest
responseDefinition:
rawResponse:
statusCode: 200
headers:
- name: content-type
value: [ "application/connect+proto" ]
stream:
items:
- flags: 2
payload:
text: |
{
"error": {
"code": "out_of_range",
"message": "oops",
"details": [
{
"type": "google.protobuf.FileDescriptorProto",
"value": "Cgp0ZXN0LnByb3Rv"
}
]
}
}
expectedResponse:
error:
code: CODE_OUT_OF_RANGE
message: oops
details:
- "@type": type.googleapis.com/google.protobuf.FileDescriptorProto
name: "test.proto"
Loading