Failed to load assets

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

All the assets were in the CMS and without any reason it is failing to load all the assets in our squidex installation

Expected behavior

Assets should be present

Minimal reproduction of the problem

Environment

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

Version: [VERSION] 4.0.3

Browser:

  • [ ] Chrome (desktop)
  • [ ] Chrome (Android)
  • [ ] Chrome (iOS)
  • [ ] Firefox
  • [ ] Safari (desktop)
  • [ ] Safari (iOS)
  • [ ] IE
  • [ ] Edge

Others:

Squidex log file:

{
  "logLevel": "Error",
  "message": "Connection id \u00220HM3N587420DL\u0022, Request id \u00220HM3N587420DL:00000003\u0022: An unhandled exception was thrown by the application.",
  "eventId": {
    "id": 13,
    "name": "ApplicationError"
  },
  "connectionId": "0HM3N587420DL",
  "traceIdentifier": "0HM3N587420DL:00000003",
  "exception": {
    "type": "System.FormatException",
    "message": "Element \u0027md\u0027 does not match any field or property of class Squidex.Domain.Apps.Entities.MongoDb.Assets.MongoAssetEntity.",
    "stackTrace": "   at MongoDB.Bson.Serialization.BsonClassMapSerializer\u00601.DeserializeClass(BsonDeserializationContext context)\n   at MongoDB.Bson.Serialization.BsonClassMapSerializer\u00601.Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)\n   at MongoDB.Bson.Serialization.IBsonSerializerExtensions.Deserialize[TValue](IBsonSerializer\u00601 serializer, BsonDeserializationContext context)\n   at MongoDB.Driver.Core.Operations.CursorBatchDeserializationHelper.DeserializeBatch[TDocument](RawBsonArray batch, IBsonSerializer\u00601 documentSerializer, MessageEncoderSettings messageEncoderSettings)\n   at MongoDB.Driver.Core.Operations.FindCommandOperation\u00601.CreateCursorBatch(BsonDocument commandResult)\n   at MongoDB.Driver.Core.Operations.FindCommandOperation\u00601.CreateCursor(IChannelSourceHandle channelSource, BsonDocument commandResult)\n   at MongoDB.Driver.Core.Operations.FindCommandOperation\u00601.ExecuteAsync(RetryableReadContext context, CancellationToken cancellationToken)\n   at MongoDB.Driver.Core.Operations.FindOperation\u00601.ExecuteAsync(RetryableReadContext context, CancellationToken cancellationToken)\n   at MongoDB.Driver.Core.Operations.FindOperation\u00601.ExecuteAsync(IReadBinding binding, CancellationToken cancellationToken)\n   at MongoDB.Driver.OperationExecutor.ExecuteReadOperationAsync[TResult](IReadBinding binding, IReadOperation\u00601 operation, CancellationToken cancellationToken)\n   at MongoDB.Driver.MongoCollectionImpl\u00601.ExecuteReadOperationAsync[TResult](IClientSessionHandle session, IReadOperation\u00601 operation, ReadPreference readPreference, CancellationToken cancellationToken)\n   at MongoDB.Driver.MongoCollectionImpl\u00601.UsingImplicitSessionAsync[TResult](Func\u00602 funcAsync, CancellationToken cancellationToken)\n   at MongoDB.Driver.IAsyncCursorSourceExtensions.ToListAsync[TDocument](IAsyncCursorSource\u00601 source, CancellationToken cancellationToken)\n   at Squidex.Domain.Apps.Entities.MongoDb.Assets.MongoAssetRepository.QueryAsync(Guid appId, ClrQuery query) in /home/amz/Workspace/swarm/imperial-auto/imperial-auto-cms/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Assets/MongoAssetRepository.cs:line 74\n   at Squidex.Domain.Apps.Entities.Assets.Queries.AssetQueryService.QueryByQueryAsync(Context context, Q query) in /home/amz/Workspace/swarm/imperial-auto/imperial-auto-cms/backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/AssetQueryService.cs:line 82\n   at Squidex.Domain.Apps.Entities.Assets.Queries.AssetQueryService.QueryAsync(Context context, Q query) in /home/amz/Workspace/swarm/imperial-auto/imperial-auto-cms/backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/AssetQueryService.cs:line 70\n   at Squidex.Areas.Api.Controllers.Assets.AssetsController.GetAssets(String app, String ids, String q) in /home/amz/Workspace/swarm/imperial-auto/imperial-auto-cms/backend/src/Squidex/Areas/Api/Controllers/Assets/AssetsController.cs:line 108\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.\u003CInvokeActionMethodAsync\u003Eg__Awaited|12_0(ControllerActionInvoker invoker, ValueTask\u00601 actionResultValueTask)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.\u003CInvokeNextActionFilterAsync\u003Eg__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State\u0026 next, Scope\u0026 scope, Object\u0026 state, Boolean\u0026 isCompleted)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.\u003CInvokeInnerFilterAsync\u003Eg__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.\u003CInvokeNextExceptionFilterAsync\u003Eg__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ExceptionContextSealed context)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State\u0026 next, Scope\u0026 scope, Object\u0026 state, Boolean\u0026 isCompleted)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.\u003CInvokeNextResourceFilter\u003Eg__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State\u0026 next, Scope\u0026 scope, Object\u0026 state, Boolean\u0026 isCompleted)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.\u003CInvokeFilterPipelineAsync\u003Eg__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.\u003CInvokeAsync\u003Eg__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)\n   at Microsoft.AspNetCore.Routing.EndpointMiddleware.\u003CInvoke\u003Eg__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)\n   at NSwag.AspNetCore.Middlewares.OpenApiDocumentMiddleware.Invoke(HttpContext context)\n   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)\n   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)\n   at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)\n   at Squidex.Web.Pipeline.EnforceHttpsMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) in /home/amz/Workspace/swarm/imperial-auto/imperial-auto-cms/backend/src/Squidex.Web/Pipeline/EnforceHttpsMiddleware.cs:line 28\n   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.\u003C\u003Ec__DisplayClass5_1.\u003C\u003CUseMiddlewareInterface\u003Eb__1\u003Ed.MoveNext()\n--- End of stack trace from previous location where exception was thrown ---\n   at Squidex.Web.Pipeline.LocalCacheMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) in /home/amz/Workspace/swarm/imperial-auto/imperial-auto-cms/backend/src/Squidex.Web/Pipeline/LocalCacheMiddleware.cs:line 30\n   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.\u003C\u003Ec__DisplayClass5_1.\u003C\u003CUseMiddlewareInterface\u003Eb__1\u003Ed.MoveNext()\n--- End of stack trace from previous location where exception was thrown ---\n   at Squidex.Web.Pipeline.RequestLogPerformanceMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) in /home/amz/Workspace/swarm/imperial-auto/imperial-auto-cms/backend/src/Squidex.Web/Pipeline/RequestLogPerformanceMiddleware.cs:line 33\n   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.\u003C\u003Ec__DisplayClass5_1.\u003C\u003CUseMiddlewareInterface\u003Eb__1\u003Ed.MoveNext()\n--- End of stack trace from previous location where exception was thrown ---\n   at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)\n   at Microsoft.AspNetCore.Builder.Extensions.MapWhenMiddleware.Invoke(HttpContext context)\n   at Microsoft.AspNetCore.Builder.Extensions.MapWhenMiddleware.Invoke(HttpContext context)\n   at Microsoft.AspNetCore.Builder.Extensions.MapWhenMiddleware.Invoke(HttpContext context)\n   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication\u00601 application)"
  },
  "app": {
    "name": "Squidex",
    "version": "1.0.0.0",
    "sessionId": "961c4e04-85c4-471d-941d-8e5df6e4c419"
  },
  "web": {
    "requestId": "b110da25-dd7d-4c53-875c-8f6262ab3870",
    "requestPath": "/api/apps/motuscars/assets",
    "requestMethod": "GET"
  },
  "timestamp": "2020-10-23T08:03:00Z",
  "category": "Microsoft.AspNetCore.Server.Kestrel"
}

If you have read the docs (first checkbox) then you should know what to do with logs :wink:

?
Let me ask the question then: Why would assets fail to load ?

I meant: Please format your logs in the post properly with code blocks.

But it sounds like you have downgraded Squidex. Because “md” is definitely a field in the asset collection: https://github.com/Squidex/squidex/blob/master/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Assets/MongoAssetEntity.cs#L103

Noted and thank you.

Havent downgraded. Everything was 100%. Client was uploading assets this morning for posts in the CMS and then it stopped loading assets

Do you have multiple servers on the same database? I have no other explanation than version mismatch somewhere.

You can fix it by running an update over the collection, something like { $unset: "md" }, but it does not explain the issue.

In 4.0.3 this field does not exist indeed: https://github.com/Squidex/squidex/blob/77c3154028e7024acb35908cf30ed4a3b1373e88/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Assets/MongoAssetEntity.cs

So there must have been a downgrade somehow. Perhaps a restored backup or whatever.

{ 
"_id" : "001d59d7-0156-4b03-94ae-66c35f73d38d", 
"_ai" : "61c3f085-9785-4424-89e0-3ee12260bd43", 
"ct" : ISODate("2020-06-11T19:56:23.000+0000"), 
"mt" : ISODate("2020-06-11T19:56:23.000+0000"), 
"ai" : {
    "_id" : BinData(3, "hfDDYYWXJESJ4D7hImC9Qw=="), 
    "Name" : "imperialauto"
}, 
"mm" : "image/jpeg", 
"fn" : "RC-F Lifestyle image 4.jpg", 
"fh" : "COIr2k/Bb7mcCyGhBWuMnC4gI6PiltysVc2jDpO4srs=", 
"sl" : "rc-f-lifestyle-image-4.jpg", 
"fs" : NumberLong(251379), 
"fv" : NumberLong(0), 
"vs" : NumberLong(0), 
"cb" : "subject:5eaeceae0d50e55a5d4ae905", 
"mb" : "subject:5eaeceae0d50e55a5d4ae905", 
"td" : [
    "eff4bf5a-fe2f-48f2-8bc2-af3184c24f25", 
    "032df9e9-20e2-4848-9a63-0b1df54ff2dd", 
    "f65ec1fe-735c-4c3e-a1dd-0aacc45860be"
], 
"dl" : false, 
"md" : {
    "pixelHeight" : NumberInt(1080), 
    "pixelWidth" : NumberInt(1920)
}, 
"at" : "Image"

}

This is where there is an md reference in mongo

Yes, but this comes from a version newer than 4.0.3

We installed a newer version of squidex to test updating the version we have. We linked it to the current live database to pull in the relevant schemas and content, but that was all. Could it be that the new version will affect the mongodb when started up?

Very likely, this is the case.

that was the case. Restored a backup of the squidex mongo collection and working again

1 Like

Next time you can also try rebuilding the collections: There are a few flags: https://github.com/Squidex/squidex/blob/master/backend/src/Squidex/appsettings.json#L683

Almost everything can be restored from the events. You just have to enable the flags, restart, disable the flags, restart.

Thank you. will try that on the dev environments