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

Outputs more detailed logs to help quickly locate problems #15978

Closed
hyzx86 opened this issue May 5, 2024 · 4 comments
Closed

Outputs more detailed logs to help quickly locate problems #15978

hyzx86 opened this issue May 5, 2024 · 4 comments

Comments

@hyzx86
Copy link
Contributor

hyzx86 commented May 5, 2024

Is your feature request related to a problem? Please describe.

I ran into a strange problem today, it appeared in a unit test and it was hard to find out exactly what was causing it. I ended up overriding the implementation of the ContentPartFactory class in my program, and then debugging through breakpoints to find the real cause of the problem. #15979

An unhandled exception has occurred while executing the request. System.ArgumentNullException: Value cannot be null. (Parameter 'key')
   at System.Collections.Generic.Dictionary`2.FindValue(TKey key)
   at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
   at OrchardCore.ContentManagement.ContentPartFactory.GetTypeActivator(String partName)
   at OrchardCore.ContentManagement.GraphQL.Queries.Types.TypedContentTypeBuilder.Build(FieldType contentQuery, ContentTypeDefinition contentTypeDefinition, ContentItemType contentItemType)
   at OrchardCore.ContentManagement.GraphQL.Queries.ContentTypeQuery.BuildAsync(ISchema schema)
   at OrchardCore.Apis.GraphQL.Services.SchemaService.GetSchemaAsync()
   at OrchardCore.Apis.GraphQL.GraphQLMiddleware.ExecuteAsync(HttpContext context, ISchemaFactory schemaService, IDocumentWriter documentWriter)
   at OrchardCore.Apis.GraphQL.GraphQLMiddleware.Invoke(HttpContext context, IAuthorizationService authorizationService, IAuthenticationService authenticationService, ISchemaFactory schemaService, IDocumentWriter documentWriter)
   at SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.Invoke(HttpContext httpContext, Boolean retry)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at OrchardCore.Liquid.ScriptsMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at OrchardCore.Diagnostics.DiagnosticsStartupFilter.<>c__DisplayClass3_0.<<Configure>b__1>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.<Invoke>g__Awaited|10_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)    at System.Collections.Generic.Dictionary`2.FindValue(TKey key)
   at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
   at OrchardCore.ContentManagement.ContentPartFactory.GetTypeActivator(String partName)
   at OrchardCore.ContentManagement.GraphQL.Queries.Types.TypedContentTypeBuilder.Build(FieldType contentQuery, ContentTypeDefinition contentTypeDefinition, ContentItemType contentItemType)
   at OrchardCore.ContentManagement.GraphQL.Queries.ContentTypeQuery.BuildAsync(ISchema schema)
   at OrchardCore.Apis.GraphQL.Services.SchemaService.GetSchemaAsync()
   at OrchardCore.Apis.GraphQL.GraphQLMiddleware.ExecuteAsync(HttpContext context, ISchemaFactory schemaService, IDocumentWriter documentWriter)
   at OrchardCore.Apis.GraphQL.GraphQLMiddleware.Invoke(HttpContext context, IAuthorizationService authorizationService, IAuthenticationService authenticationService, ISchemaFactory schemaService, IDocumentWriter documentWriter)
   at SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.Invoke(HttpContext httpContext, Boolean retry)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at OrchardCore.Liquid.ScriptsMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at OrchardCore.Diagnostics.DiagnosticsStartupFilter.<>c__DisplayClass3_0.<<Configure>b__1>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.<Invoke>g__Awaited|10_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)

Describe the solution you'd like

Most of the time we throw exceptions directly in OC without secondary processing, which is not friendly to developers who use OC for secondary development. I hope we can add some descriptions to the logs to help developers quickly locate the problem.

@Piedone
Copy link
Member

Piedone commented May 5, 2024

This is an unexpected exception thrown by a .NET type (most possibly due to a result of a coding error). If an error is something that OC checks and throws an exception for, then that should be easier to understand.

What exactly would you expect OC to do? Note that this exception is not deliberate. BTW you can increase the general log level in e.g. your appsettings file.

@hyzx86
Copy link
Contributor Author

hyzx86 commented May 6, 2024

Yes, this problem can be unforeseen and is mainly caused by the PartName property is null.

A merge of #15979 should ignore this problem!

@hyzx86 hyzx86 closed this as completed May 6, 2024
@hyzx86
Copy link
Contributor Author

hyzx86 commented May 6, 2024

Yes, this problem can only be dealt with on a case-by-case basis.

@Piedone
Copy link
Member

Piedone commented May 6, 2024

I agree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants