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

NPE when calling CreateQuery with ExamineX 3.0 beta and Umbraco v9 #51

Closed
wvankesteren-ax opened this issue Nov 9, 2021 · 5 comments
Closed
Milestone

Comments

@wvankesteren-ax
Copy link

wvankesteren-ax commented Nov 9, 2021

Hi,

We are implementing usage of ExamineX in Umbraco v9, but upon the call to CreateQuery("content") an NPE occurs, stating the fields parameter is null.

IQuery query = index.Searcher.CreateQuery(IndexTypes.Content);

call stack:

System.ArgumentNullException: Value cannot be null. (Parameter 'fields')
   at ExamineX.AzureSearch.AzureSearchQuery.A(IReadOnlyList`1 , String )
   at ExamineX.AzureSearch.AzureSearchQuery..ctor(SearchClient indexClient, ILoggerFactory loggerFactory, String analyzer, String category, AzureSearchFieldReferences fields, BooleanOperation occurance)
   at ExamineX.AzureSearch.AzureSearchSearcher.CreateQuery(String category, BooleanOperation defaultOperation)
   at Umb.Platform.Web.Core.Controller.ActueelPageController.Init(ActueelPageModel lhs, IPublishedContent rhs, HttpRequest request) in C:\disk\d\dev\umb.platform\Umb.Platform.Web.Core\Controller\ActueelPageController.cs:line 123
   at Umb.Platform.Web.Core.Controller.ActueelPageController.Index() in C:\disk\d\dev\umb.platform\Umb.Platform.Web.Core\Controller\ActueelPageController.cs:line 200
   at lambda_method289(Closure , Object , Object[] )
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Logged|12_1(ControllerActionInvoker invoker)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ExceptionContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeNextResourceFilter()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Umbraco.StorageProviders.AzureBlob.AzureBlobFileSystemMiddleware.HandleRequestAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location ---
   at Umbraco.Cms.Web.Common.Middleware.BasicAuthenticationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location ---
   at Umbraco.Cms.Web.BackOffice.Middleware.BackOfficeExternalLoginProviderErrorMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
   at StackExchange.Profiling.MiniProfilerMiddleware.Invoke(HttpContext context) in C:\projects\dotnet\src\MiniProfiler.AspNetCore\MiniProfilerMiddleware.cs:line 121
   at Umbraco.Cms.Web.Common.Middleware.UmbracoRequestMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Umbraco.Cms.Web.Common.Middleware.UmbracoRequestMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location ---
   at Umbraco.Cms.Web.Common.Middleware.PreviewAuthenticationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location ---
   at Umbraco.Cms.Web.Common.Middleware.UmbracoRequestLoggingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

https://our.umbraco.com/forum/umbraco-9//107534-examinex-with-unbraco-v9

@Shazwazza
Copy link
Contributor

I can see where this error is being thrown and will adjust the logic to not throw if there are no fields. However, there should be fields there unless you are testing this with a completely empty Umbraco installation? Else, can you describe how to replicate the issue from a vanilla Umbraco install?

@Shazwazza
Copy link
Contributor

I can see this could occur if the Azure Search index is empty. Have you tried rebuilding the ExamineX index via the back office first?

I'll push an update to ExamineX 3.0 so that it doesn't throw when this is the case. Hopefully by tomorrow.

@wvankesteren-ax
Copy link
Author

wvankesteren-ax commented Nov 10, 2021 via email

@Shazwazza
Copy link
Contributor

Hi, yes please let me know if rebuilding resolves the issue. This shouldn't be a requirement of ExamineX since Umbraco will automatically rebuild indexes if they don't exist. This occurs after startup and is on a minute or two delay. There's a possibility that when you enable ExamineX and the app is restarted, that you are getting this error before Umbraco kicks off the index rebuild.

I have fixed the exception issue but would be interesting to know if rebuilding resolves the issue too so I will know the exact root cause. Then I can create a new release.

Thanks!

@wvankesteren-ax
Copy link
Author

wvankesteren-ax commented Nov 11, 2021 via email

@Shazwazza Shazwazza added this to the 3.0.0 milestone Dec 13, 2021
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

2 participants