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

[Bug]: System.InvalidOperationException: TryParse method found on Guid with incorrect format #3117

Open
kirillkrylov opened this issue Oct 23, 2024 · 2 comments
Labels
bug stale Stale issues or pull requests

Comments

@kirillkrylov
Copy link

Describe the bug

This line causes the error

jobsApi.MapGet("/Status/{id:guid}",JobStatusById);

however this works as expected

jobsApi.MapGet("/Status/{id}",JobStatusById);

image

Expected behavior

Not throw

Actual behavior

Throws exeption

Steps to reproduce

No response

Exception(s) (if any)

Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HN7JJO47LKTO", Request id "0HN7JJO47LKTO:00000002": An unhandled exception was thrown by the application.
      System.InvalidOperationException: TryParse method found on Guid with incorrect format. Must be a static method with format
      bool TryParse(string, IFormatProvider, out Guid)
      bool TryParse(string, out Guid)
      but found
      static Boolean TryParse(System.String, System.IFormatProvider, System.Guid ByRef)
         at Microsoft.AspNetCore.Http.ParameterBindingMethodCache.<FindTryParseMethod>g__Finder|14_0(Type type) + 0x83d
         at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey, Func`2) + 0xa4
         at Microsoft.AspNetCore.Http.ParameterBindingMethodCache.HasTryParseMethod(Type) + 0x26
         at Microsoft.AspNetCore.Mvc.ApiExplorer.EndpointMetadataApiDescriptionProvider.GetBindingSourceAndName(ParameterInfo, RoutePattern, Boolean) + 0x674
         at Microsoft.AspNetCore.Mvc.ApiExplorer.EndpointMetadataApiDescriptionProvider.CreateApiParameterDescription(ParameterInfo, RoutePattern, Boolean) + 0x52
         at Microsoft.AspNetCore.Mvc.ApiExplorer.EndpointMetadataApiDescriptionProvider.CreateApiDescription(RouteEndpoint, String, MethodInfo, Boolean) + 0x290
         at Microsoft.AspNetCore.Mvc.ApiExplorer.EndpointMetadataApiDescriptionProvider.OnProvidersExecuting(ApiDescriptionProviderContext) + 0x322
         at Microsoft.AspNetCore.Mvc.ApiExplorer.ApiDescriptionGroupCollectionProvider.GetCollection(ActionDescriptorCollection) + 0x4f
         at Microsoft.AspNetCore.Mvc.ApiExplorer.ApiDescriptionGroupCollectionProvider.get_ApiDescriptionGroups() + 0x35
         at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GetSwaggerDocumentWithoutPaths(String, String, String) + 0x76
         at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.<GetSwaggerAsync>d__6.MoveNext() + 0x6f
      --- End of stack trace from previous location ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
         at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xb2
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task, ConfigureAwaitOptions) + 0x4b
         at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.<Invoke>d__6.MoveNext() + 0x219
      --- End of stack trace from previous location ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
         at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xb2
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task, ConfigureAwaitOptions) + 0x4b
         at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.<ProcessRequests>d__238`1.MoveNext() + 0x404

Swashbuckle.AspNetCore version

6.9.0

.NET Version

8.0.403

Anything else?

issue reproducible in AOT

@martincostello
Copy link
Collaborator

martincostello commented Oct 23, 2024

The stack trace suggests this is an issue in ASP.NET Core, rather than Swashbuckle - we're just calling into its API Description layer.

If it is an issue here, then we'll need a minimal reproducible example as a GitHub repository that demonstrates the issue you're experiencing so we can look into this further with the debugger. The example as-given is missing the endpoint method itself, as well as the project configuration (you mention native AoT, for example).

Copy link
Contributor

This issue is stale because it has been open for 60 days with no activity. It will be automatically closed in 14 days if no further updates are made.

@github-actions github-actions bot added the stale Stale issues or pull requests label Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug stale Stale issues or pull requests
Projects
None yet
Development

No branches or pull requests

2 participants