Exceptions during startup for polymorphic types
See original GitHub issueI’m getting the following exception during application startup for polymorphic types. I don’t have time right now to try and mock something reproducible, but let me know if this is enough to get you started.
This exception is the derived type, but I also get a very similar exception for the base type, QueryBuilderBase.
[2021-01-26 18:35:05.495] [WRN] [MicroElements.Swashbuckle.FluentValidation.FluentValidationRules] [R:80000026-0000-fe00-b63f-84710c7967bb|T:cfb2b7e2dec6de49bd5c0d020c65d981|S:30ccdb394b7e8940] Applying IncludeRules for type 'QueryBuilder.Models.QueryBuilderQuery' fails.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.NullReferenceException: Object reference not set to an instance of an object.
at FluentValidation.Validators.PropertyValidatorContext.get_PropertyValue() in /home/jskinner/code/FluentValidation/src/FluentValidation/Validators/PropertyValidatorContext.cs:line 52
at FluentValidation.Validators.PolymorphicValidator`2.GetValidator(PropertyValidatorContext context) in /home/jskinner/code/FluentValidation/src/FluentValidation/Validators/PolymorphicValidator.cs:line 103
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at MicroElements.Swashbuckle.FluentValidation.FluentValidationSchemaBuilder.GetValidatorFromChildValidatorAdapter(IChildValidatorAdaptor childValidatorAdapter) in /home/runner/work/MicroElements.Swashbuckle.FluentValidation/MicroElements.Swashbuckle.FluentValidation/src/MicroElements.Swashbuckle.FluentValidation/FluentValidationSchemaBuilder.cs:line 140
at MicroElements.Swashbuckle.FluentValidation.FluentValidationSchemaBuilder.AddRulesFromIncludedValidators(OpenApiSchema schema, SchemaFilterContext schemaFilterContext, IValidator validator, IReadOnlyCollection`1 rules, ILogger logger) in /home/runner/work/MicroElements.Swashbuckle.FluentValidation/MicroElements.Swashbuckle.FluentValidation/src/MicroElements.Swashbuckle.FluentValidation/FluentValidationSchemaBuilder.cs:line 106
at MicroElements.Swashbuckle.FluentValidation.FluentValidationSchemaBuilder.AddRulesFromIncludedValidators(OpenApiSchema schema, SchemaFilterContext schemaFilterContext, IValidator validator, IReadOnlyCollection`1 rules, ILogger logger) in /home/runner/work/MicroElements.Swashbuckle.FluentValidation/MicroElements.Swashbuckle.FluentValidation/src/MicroElements.Swashbuckle.FluentValidation/FluentValidationSchemaBuilder.cs:line 106
at MicroElements.Swashbuckle.FluentValidation.FluentValidationRules.AddRulesFromIncludedValidators(OpenApiSchema schema, SchemaFilterContext context, IValidator validator) in /home/runner/work/MicroElements.Swashbuckle.FluentValidation/MicroElements.Swashbuckle.FluentValidation/src/MicroElements.Swashbuckle.FluentValidation/FluentValidationRules.cs:line 96
at MicroElements.Swashbuckle.FluentValidation.FluentValidationRules.Apply(OpenApiSchema schema, SchemaFilterContext context) in /home/runner/work/MicroElements.Swashbuckle.FluentValidation/MicroElements.Swashbuckle.FluentValidation/src/MicroElements.Swashbuckle.FluentValidation/FluentValidationRules.cs:line 68
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
What is this? catching polymorphic type X by value
By catching a value, you are effectively using just the base class of the exception thrown (regardless of the type actually thrown). Instead, ......
Read more >The hard part of checked exceptions is when they start ...
The hard part of checked exceptions is when they start interacting with higher order code- in Java this often happens when an interface ......
Read more >Catch blocks can be polymorphic. (Beginning Java forum ...
catch blocks can be polymorphic. On page 330, it explains this statement by saying that Exceptions can be referred to polymorphically.
Read more >Fix these 10 common examples of the RuntimeException in ...
Here are 10 examples of how to avoid runtime exceptions in Java. ... one object to another unless they share a polymorphic relationship....
Read more >Exception Handling with Method Overriding in Java
An Exception is an unwanted or unexpected event, which occurs during the execution of a program i.e at run-time, that disrupts the normal ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yeah I’ll see if I can’t add something in SampleWebApi (App?) to repro and send you a PR. Might be next week.
Can you add sample in SampleWebApp or test?