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 details about underlying message types on input message protocol errors #1252

Closed
wants to merge 2 commits into from
Closed
Changes from all 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
30 changes: 27 additions & 3 deletions packages/connect/src/protocol/invoke-implementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,16 @@ export function transformInvokeImplementation<
const input2 = await inputIt.next();
if (input2.done !== true) {
throw new ConnectError(
"protocol error: received extra input message for unary method",
`protocol error: received extra input message ${spec.method.I.typeName} for unary method ${spec.method.name}`,
Copy link
Member

@srikrsna-buf srikrsna-buf Oct 7, 2024

Choose a reason for hiding this comment

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

Fully qualified method name is unique and will be sufficient to pinpoint:

Suggested change
`protocol error: received extra input message ${spec.method.I.typeName} for unary method ${spec.method.name}`,
`protocol error: received extra input message for unary method ${spec.service.typeName}.${spec.method.name}`,

Code.Unimplemented,
{
methodName: spec.method.name,
serviceTypeName: spec.service.typeName,
inputTypeName: spec.method.I.typeName,
outputTypeName: spec.method.O.typeName,
url: context.url,
requestMethod: context.requestMethod,
}
Comment on lines +154 to +161
Copy link
Member

Choose a reason for hiding this comment

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

Metadata is used for errors returned as part of the protocol, fully qualified method name should be sufficient to pin point the rpc

Copy link
Author

Choose a reason for hiding this comment

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

If I understand correctly, you are suggesting I remove this as adding metadata would interfere with other parts of the stack?

I can do that. I agree that the rpc method is the main piece of information missing.

);
}
};
Expand All @@ -160,8 +168,16 @@ export function transformInvokeImplementation<
const input1 = await inputIt.next();
if (input1.done === true) {
throw new ConnectError(
"protocol error: missing input message for server-streaming method",
`protocol error: missing input message ${spec.method.I.typeName} for server-streaming method ${spec.method.name}`,
Code.Unimplemented,
{
methodName: spec.method.name,
serviceTypeName: spec.service.typeName,
inputTypeName: spec.method.I.typeName,
outputTypeName: spec.method.O.typeName,
url: context.url,
requestMethod: context.requestMethod,
}
);
}
const anyFn = async (
Expand Down Expand Up @@ -207,8 +223,16 @@ export function transformInvokeImplementation<
const input2 = await inputIt.next();
if (input2.done !== true) {
throw new ConnectError(
"protocol error: received extra input message for server-streaming method",
`protocol error: received extra input message ${spec.method.I.typeName} for server-streaming method ${spec.method.name}`,
Code.Unimplemented,
{
methodName: spec.method.name,
serviceTypeName: spec.service.typeName,
inputTypeName: spec.method.I.typeName,
outputTypeName: spec.method.O.typeName,
url: context.url,
requestMethod: context.requestMethod,
}
);
}
};
Expand Down