dotnet / dotnet/aspnetcore

Swagger grpc throws stack overflow exception when having recursive trees as query parameters

Open
#58,624 0 comments 0 reactions 0 assignees View on GitHub
area-grpc
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

Description

Consider the following minimal rpc:
```protobuf
rpc List(ListRequest) returns (ListResponse) {
option (google.api.http) = {
get: "/api/notes/list",
};
}

message ListRequest {
ListRequestRecursive tree = 1;
}
message ListRequestRecursive {
ListRequestRecursiveChildren children = 1;
}
message ListRequestRecursiveChildren {
repeated ListRequestRecursive children = 1;
}
message ListResponse { }
```

This causes the server to throw stack overflow exception as it goes into infinite loop starting from here:

https://github.com/dotnet/aspnetcore/blob/de68d4212113859604d9e57cf7d674b167a8a317/src/Grpc/JsonTranscoding/src/Shared/ServiceDescriptorHelpers.cs#L505

workaround:
use POST instead of get:
```protobuf
rpc List(ListRequest) returns (ListResponse) {
option (google.api.http) = {
post: "/api/notes/list",
body: "*"
};
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.