Skip to content

PublishAot is breaking the aspnetcore sample app #214

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

Closed
chuckries opened this issue Apr 4, 2025 · 6 comments · Fixed by #215
Closed

PublishAot is breaking the aspnetcore sample app #214

chuckries opened this issue Apr 4, 2025 · 6 comments · Fixed by #215
Labels
bug Something isn't working

Comments

@chuckries
Copy link

Describe the bug
configuring the AspNetCoreSseServer sample for PublishAot causes default json serialization to not allow reflection which breaks the tool descriptor generation. This causes the app to thrown exception on launch

To Reproduce
Steps to reproduce the behavior:

  1. Open sln
  2. Set AspNetCoreSseServer sample project as startup project
  3. Launch under debugger

Exception is thrown:
System.NotSupportedException: 'JsonTypeInfo metadata for type 'ModelContextProtocol.Server.IMcpServer' was not provided by TypeInfoResolver of type 'Microsoft.Extensions.AI.AIJsonUtilities+JsonContext'.

Expected behavior
Server launches

@chuckries chuckries added the bug Something isn't working label Apr 4, 2025
@stephentoub
Copy link
Contributor

cc: @eiriktsarpalis, @agocke

@stephentoub
Copy link
Contributor

ModelContextProtocol.Server.IMcpServer' was not provided by TypeInfoResolver of type

Something is wrong. Nothing should be trying to serialize one of these.

@chuckries
Copy link
Author

chuckries commented Apr 4, 2025

I believe it stems from here

@halter73
Copy link
Contributor

halter73 commented Apr 4, 2025

Isn't that the line that excludes it from the schema so it won't be deserialized?

@stephentoub
Copy link
Contributor

The problem is

JsonTypeInfo typeInfo = serializerOptions.GetTypeInfo(parameterType);

That's being done too early. It needs to be moved down to L608.

@stephentoub
Copy link
Contributor

stephentoub commented Apr 4, 2025

@eiriktsarpalis already fixed that in the real AIFunctionFactory:
https://github.com/dotnet/extensions/blob/e0f0b6100f3f95b0847be14995e24cd644cd1d3a/src/Libraries/Microsoft.Extensions.AI/Functions/AIFunctionFactory.cs#L532
but we didn't make the change to TemporaryAIFunctionFactory, which will be deleted when we pick up the next M.E.AI.Abstractions package.

But we should still fix this in the meantime.

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.

4 participants