-
Notifications
You must be signed in to change notification settings - Fork 709
ArgumentNullException in ApplyContentTypeVersionActionFilter.ApplyApiVersionMediaTypeParameter(…) #528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Interesting... in starting to dig into this, I still don't see where this would happen. I don't think it's necessarily specific to The change you are seeing was included in the last patch to address echoing back the API version in the response media type. I've looked at ApplyContentTypeVersionActionFilter and the call site you pointed out, but I'm not seeing how that would result in ArgumentNullException. The stack trace seems to indicate comparison against StringSegment, but I'm not seeing that used anywhere. For completeness, can you share what you have for VendorMediaTypeApiVersionReader. I should be able to construct a repro with that. Versioning by both URL segment and media type does seem a bit odd, but it should work. It looks like you want to support multiple media type parameters. I suspect it may be related to that somehow. Thanks. |
«can you share what you have for VendorMediaTypeApiVersionReader» — Yeah, sure. I will create and upload working example of code, which leads to throwing this exception. In short — it appears because of MediaTypeApiVersionReader sets values After that reader.GetMediaTypeVersionParameter() returns |
I probably don't need a full repro, just that class should do. 💡 Duh! Now I think I see what you're saying. I tried to get trickying with inlining, but that's wrong. The This should be a simple fix. In the meantime, you should be able to unblock yourself by simply changing the order in which the IApiVersionReader instances are registered. This issue should not occur if UrlSegmentApiVersionReader is registered first. There is no short-circuiting logic. All readers are executed to account for a scenario where multiple API versions are allowed, specified, but are different (client error). Thanks. |
Yes, you right. Exactly this scenario leads to crash of application. |
FYI ... the patch for this has been published. |
ApplyContentTypeVersionActionFilter throws an exception, if ApiVersioningOptions.ApiVersionReader property initialized with ApiVersionReader.Combine(…) method:
Example of configuring API Versioning Options in our application:
Application starts crashing after migration from
Microsoft.AspNetCore.Mvc.Versioning
version3.1.2
to>= 3.1.3
. I'm investigate the problem and found that main reason of this crash is here: DescriptionContext.AddParameter(…)The text was updated successfully, but these errors were encountered: