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

Server reflection failes when either request oder response are simple types #1135

Open
AndreasSchommer opened this issue Mar 5, 2024 · 0 comments

Comments

@AndreasSchommer
Copy link

I have a service Grpc Service that accepts simple type parameters / returns simple type results. The project uses code first, so let me post the interface:

interface IMyService
{
    Task<byte[]?> Operation1(string myRequest, CallContext context = default);
}

When I call the reflection endpoint, the following Exception is raised in the service process:

Data of this type has inbuilt behaviour, and cannot be added to a model in this way: <data-type>
   bei ProtoBuf.Meta.RuntimeTypeModel.FindOrAddAuto(Type type, Boolean demand, Boolean addWithContractOnly, Boolean addEvenIfAutoDisabled, CompatibilityLevel ambient) in /_/src/protobuf-net/Meta/RuntimeTypeModel.cs: Zeile760
   bei ProtoBuf.Meta.RuntimeTypeModel.<GetSchema>g__AddType|41_1(Type type, Boolean forceOutput, Boolean inferPackageAndOrigin, <>c__DisplayClass41_0& ) in /_/src/protobuf-net/Meta/RuntimeTypeModel.cs: Zeile217
   bei ProtoBuf.Meta.RuntimeTypeModel.GetSchema(SchemaGenerationOptions options) in /_/src/protobuf-net/Meta/RuntimeTypeModel.cs: Zeile289
   bei ProtoBuf.Grpc.Reflection.SchemaGenerator.GetSchema(Type[] contractTypes) in /_/src/protobuf-net.Grpc.Reflection/SchemaGenerator.cs: Zeile127
   bei ProtoBuf.Grpc.Reflection.SchemaGenerator.GetSchema(Type contractType) in /_/src/protobuf-net.Grpc.Reflection/SchemaGenerator.cs: Zeile44
   bei ProtoBuf.Grpc.Reflection.FileDescriptorSetFactory.Populate(FileDescriptorSet fileDescriptorSet, Type serviceType, BinderConfiguration binderConfiguration) in /_/src/protobuf-net.Grpc.Reflection/FileDescriptorSetFactory.cs: Zeile47
   bei ProtoBuf.Grpc.Reflection.FileDescriptorSetFactory.Create(IEnumerable`1 serviceTypes, BinderConfiguration binderConfiguration) in /_/src/protobuf-net.Grpc.Reflection/FileDescriptorSetFactory.cs: Zeile25
   bei ProtoBuf.Grpc.Reflection.ReflectionService..ctor(BinderConfiguration binderConfiguration, Type[] types) in /_/src/protobuf-net.Grpc.Reflection/ReflectionService.cs: Zeile33
   bei ProtoBuf.Grpc.Server.ReflectionExtensions.<>c.<AddCodeFirstGrpcReflection>b__1_0(IServiceProvider serviceProvider) in /_/src/protobuf-net.Grpc.AspNetCore.Reflection/ReflectionExtensions.cs: Zeile60
   bei Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) in Microsoft.Extensions.DependencyInjection.ServiceLookup\CallSiteVisitor.cs: Zeile32
   bei Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context) in Microsoft.Extensions.DependencyInjection.ServiceLookup\CallSiteRuntimeResolver.cs: Zeile78
   bei Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument) in Microsoft.Extensions.DependencyInjection.ServiceLookup\CallSiteVisitor.cs: Zeile20
   bei Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope) in Microsoft.Extensions.DependencyInjection.ServiceLookup\CallSiteRuntimeResolver.cs: Zeile28
   bei Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(ServiceIdentifier serviceIdentifier) in Microsoft.Extensions.DependencyInjection\ServiceProvider.cs: Zeile209
   bei Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(ServiceIdentifier serviceIdentifier, ServiceProviderEngineScope serviceProviderEngineScope) in Microsoft.Extensions.DependencyInjection\ServiceProvider.cs: Zeile179
   bei Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType) in Microsoft.Extensions.DependencyInjection.ServiceLookup\ServiceProviderEngineScope.cs: Zeile70
   bei Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider) in Microsoft.Extensions.DependencyInjection\ServiceProviderServiceExtensions.cs: Zeile12
   bei Grpc.AspNetCore.Server.Internal.DefaultGrpcServiceActivator`1.Create(IServiceProvider serviceProvider) in Grpc.AspNetCore.Server.Internal\DefaultGrpcServiceActivator.cs: Zeile14
   bei Grpc.Shared.Server.DuplexStreamingServerMethodInvoker`3.<Invoke>d__4.MoveNext() in Grpc.Shared.Server\DuplexStreamingServerMethodInvoker.cs: Zeile64

I used dotnet-grpc-cli to invoke the endpoint to list available services (ls). I assume that the tool is not the problem here, since the exception is raised in the service host.

I attached a debugger and found out, that on the first instance where either input or output parameters are simple types, the exception is thrown. I'm aware that this is no good service design and understand if you don't intend to put work in a fix. Perhaps at least the error message could be somewhat improvided.

Cheers,
Andreas

@AndreasSchommer AndreasSchommer changed the title Server reflection failes wehen either request oder response are simple types Server reflection failes when either request oder response are simple types Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant