Mapping error illegal_argument_exception
See original GitHub issueI have this mapping error message on some operations. In a particular controller, it happens on delete. It wants to map some text field to boolean and fails.
Elasticsearch.Net.ElasticsearchClientException: Request failed to execute. ServerError: Type: illegal_argument_exception Reason: "mapper [entityFrameworkEvent.entries.changes.newValue] of different type, current_type [text], merged_type [boolean]" at Audit.Elasticsearch.Providers.ElasticsearchDataProvider.InsertEventAsync(AuditEvent auditEvent) at Audit.Core.AuditScope.SaveEventAsync(Boolean forceInsert) at Audit.Core.AuditScope.SaveAsync() at Audit.EntityFramework.DbContextHelper.SaveScopeAsync(IAuditDbContext context, AuditScope scope, EntityFrameworkEvent event) at Audit.EntityFramework.DbContextHelper.SaveChangesAsync(IAuditDbContext context, Func
1 baseSaveChanges)
at Audit.EntityFramework.AuditDbContext.SaveChangesAsync(CancellationToken cancellationToken)
at MyApi.Controllers.ClinicianController.DeleteClinicianAsync(Int32 clinicianId) in C:\dev\appbackend\src\MyApi\Controllers\ClinicianController.cs:line 186
at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at System.Threading.Tasks.ValueTask1.get_Result() at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync() at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync() at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync() at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter() at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync() at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync() at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context) at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIIndexMiddleware.Invoke(HttpContext httpContext) at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
But it logs perfectly on an insert operation in this same controller.
Version used
- Audit.EntityFramework.Core: 12.3.5
- Audit.Net.Elasticsearch: 12.3.5
- Elasticsearch docker image: docker.elastic.co/elasticsearch/elasticsearch:6.3.1
API referencing Audit components is in a docker container while elasticsearch is on another one.
It used to work well with older version of the elasticsearch image (6.2.4) and Audit components version 12.1.11.
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (6 by maintainers)
Top GitHub Comments
There is another way you can avoid this problem from client-side, and is making sure all the
object
properties of the audit event are serialized in the same way, for example as a JSON string.For the EF event you could override the values in a custom action as follows:
So you end up having records like:
Este misma solucion me toco aplicar al momento de integrar EntityFramework con ElasticSearch, al momento de actualizar pasaba lo mismo, tengo mis dudas con el rendimiento de esto.