[SOLVED] Sorting content throws error

I have…

I’m submitting a…

  • [ ] Regression (a behavior that stopped working in a new release)
  • [x] Bug report
  • [ ] Performance issue
  • [ ] Documentation issue or request

Current behavior

I found this error in the log. It seems to appear when i try browse content sorted by text field which contains empty/null value.

{message: ‘Object reference not set to an instance of an object.’, stackTrace: ’ at Squidex.Domain.Apps.Entities.MongoDb.Contents.Operations.Extensions.<>c.b__6_0(IdOnly x) in /src/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/Extensions.cs:line 120
at System.Linq.Enumerable.SelectListIterator2.ToList() at Squidex.Domain.Apps.Entities.MongoDb.Contents.Operations.Extensions.QueryContentsAsync(IMongoCollection1 collection, FilterDefinition`1 filter, ClrQuery query, Q q, CancellationToken ct) in /src/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/Extensions.cs:line 132
at Squidex.Domain.Apps.Entities.MongoDb.Contents.Operations.QueryByQuery.QueryAsync(ISchemaEntity schema, Q q, CancellationToken ct) in /src/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/QueryByQuery.cs:line 127
at Squidex.Domain.Apps.Entities.MongoDb.Contents.MongoContentCollection.QueryAsync(IAppEntity app, ISchemaEntity schema, Q q, CancellationToken ct) in /src/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentCollection.cs:line 216
at Squidex.Domain.Apps.Entities.Contents.Queries.ContentQueryService.QueryCoreAsync(Context context, Q q, ISchemaEntity schema, CancellationToken ct) in /src/src/Squidex.Domain.Apps.Entities/Contents/Queries/ContentQueryService.cs:line 274
at Squidex.Domain.Apps.Entities.Contents.Queries.ContentQueryService.QueryAsync(Context context, String schemaIdOrName, Q q, CancellationToken ct) in /src/src/Squidex.Domain.Apps.Entities/Contents/Queries/ContentQueryService.cs:line 140
at Squidex.Areas.Api.Controllers.Contents.ContentsController.GetContentsPost(String app, String schema, QueryDto query) in /src/src/Squidex/Areas/Api/Controllers/Contents/ContentsController.cs:line 132
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Logged|12_1(ControllerActionInvoker invoker)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.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.g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)’, type: ‘System.NullReferenceException’}

Expected behavior

Minimal reproduction of the problem

Environment

  • [x] Self hosted with docker
  • [ ] Self hosted with IIS
  • [ ] Self hosted with other version
  • [ ] Cloud version

Version: 7.8.1.0

I cannot reproduce this. I created a schema with a single string field.

Here i can add query sent by squidex

{"q":{"sort":[{"path":"data.Description.cs","order":"ascending"}],"filter":{"and":[]},"take":10,"skip":10}}

and result:

{
    "message": "",
    "traceId": "00-c16861dc0275121bb93b9ce1f399c4b2-8a5cdecb1ed6dc14-01",
    "type": "https://www.rfc-editor.org/rfc/rfc7231#section-6.6.1",
    "statusCode": 500
}

It’s thrown only if i try to load the second page. First page always (?) works.

I have just pushed a fix. It was indeed a bug in the query system.

1 Like

This topic was automatically closed after 2 days. New replies are no longer allowed.