equinor / flotilla

Flotilla is the main point of access for operators to interact with multiple robots in a facility.
Eclipse Public License 2.0
16 stars 38 forks source link

Unable to filter mission definitions by string #1704

Closed andchiind closed 3 months ago

andchiind commented 3 months ago

Describe the bug When trying to filter missions by their name we get an exception and a consequent 500 status code returned in Swagger.

To Reproduce image

Expected behavior The bug in the filtering of mission definitions in the backend should be fixed and we should also catch any exceptions and instead return 400 status codes when something fails.

Screenshots Here is a printout of the 500 error received when running the above mentioned request in the Dev Swagger: System.InvalidOperationException: The LINQ expression 'DbSet() .Join( inner: DbSet(), outerKeySelector: m => EF.Property(m, "AreaId"), innerKeySelector: a => EF.Property(a, "Id"), resultSelector: (o, i) => new TransparentIdentifier<MissionDefinition, Area>( Outer = o, Inner = i )) .Join( inner: DbSet(), outerKeySelector: m => EF.Property(m.Inner, "InstallationId"), innerKeySelector: i => EF.Property(i, "Id"), resultSelector: (o, i) => new TransparentIdentifier<TransparentIdentifier<MissionDefinition, Area>, Installation>( Outer = o, Inner = i )) .Where(m => m.Outer.Inner == null || accessibleInstallationCodes_Result_0 .Contains(m.Inner.InstallationCode.ToUpper())) .Where(m => m.Outer.Outer.IsDeprecated == False) .Where(m => m.Outer.Outer.InstallationCode.ToLower().Equals(ToLower_1) && True && True) .Where(m => m.Outer.Outer.Name != null && m.Outer.Outer.Name.Contains( value: Trim_2, comparisonType: OrdinalIgnoreCase))' could not be translated. Additional information: Translation of method 'string.Contains' failed. If this method can be mapped to your custom function, see https://go.microsoft.com/fwlink/?linkid=2132413 for more information. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information. at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.Translate(Expression expression) at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.Translate(Expression expression) at Microsoft.EntityFrameworkCore.Query.QueryCompilationContext.CreateQueryExecutor[TResult](Expression query) at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult](Expression query, Boolean async) at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async) at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass12_0`1.b0() at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func1 compiler) at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteAsync[TResult](Expression query, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ExecuteAsync[TSource,TResult](MethodInfo operatorMethodInfo, IQueryable1 source, Expression expression, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.CountAsync[TSource](IQueryable1 source, CancellationToken cancellationToken) at Api.Utilities.PagedList1.ToPagedListAsync(IQueryable`1 source, Int32 pageNumber, Int32 pageSize) at Api.Services.MissionDefinitionService.ReadAll(MissionDefinitionQueryStringParameters parameters) in /source/api/Services/MissionDefinitionService.cs:line 81 at Api.Controllers.MissionDefinitionController.GetMissionDefinitions(MissionDefinitionQueryStringParameters parameters) in /source/api/Controllers/MissionDefinitionController.cs:line 34 at lambda_method804(Closure, Object) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.gLogged|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.InvokeInnerFilterAsync() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.gAwaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext) at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider) at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)