-
-
Notifications
You must be signed in to change notification settings - Fork 158
NotFoundResult throws NullReferenceException #620
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
I see where there is a method The method is setting the |
Hi @crgolden, thanks again for opening up an issue. Your feedback has been pretty helpful. There's a few things going on here Stacktraces in error resultsIt indeed seems that the settings for including stack traces in the error outputs is communicated throughout the framework using static fields on the singleton Unfortunately right now this static config is accessed in places where DI currently can't reach (extension methods of For now I've exposed the internally used |
NullReferenceExceptionThanks for pointing that out. I've identified the issue and working on a fix. Note that in your test you're expecting a payload, the json:api spec spec doesn't necessarily require the server to return a payload. In our current implementation we do however return an error object. |
Alpha4 has been released and should be available in NuGet as a prerelease any minute |
@maurei Thanks so much for your explanations - they are very helpful. I'll have to wait on trying out the new version. My workplace has not put .NET Core 3.0 into its internal CI pipelines yet. I realize that in order to use features like MVC, ASP.NET Core 3.0 is all-or-nothing now due to the Shared Framework and discontinuation of individual NuGet packages (like Mvc.Core). It may have been impractical for you guys to support ASP.NET Core 3.0 without targeting |
@crgolden Indeed, it wasn't feasible to introduce such backward compatibility. You can work around the null reference exception you encountered by relying on conventional routing, i.e. don't use |
Ahh... ok. Thanks for the tip. The reason I'm using the I have tried setting the namespace on the Thanks again. |
Interesting, I didn't know about the features addressed in that reference. This means you're currently using multiple versions for a particular route, right? That currently won't work: the value of namespace in In your case I would recommend to stick to attribute-based routing and work around the For better configurability of stacktraces in error responses, you can add an extension similar to this one which should be enough for your needs. |
@maurei Thanks for the response. I did have a chance to try out the v4.0.0-alpha4 release. There were a surprising number of breaking changes. I have been able to work through most of them, but I would like to share a few observations:
The enhanced Resource Hooks and ASP.NET Core 3.0 support are nice, but using this new version comes at quite a price. Unfortunately, I wasn't able to find any "migration guides" to help overcome the numerous breaking changes. I have more observations but I'll end here as I'm interested to hear your thoughts. |
Thanks for the in depth comment. I will reply to everything in detail, but some things I need to first consider carefully. But starting with a few things for which the answer is more straightforward:
In v3.1 there existed two data types that represented a It wasn't necessary to have these two different classes for the same type of API response, and made it significantly hard to create (the start of) a json:api client. These classes have been merged into
If you know at precompile time response form (single or many) your API, you can just use
Note that v4.0 introduces easier (de)serialization: for client-side (de)serialization (eg in functional tests) you shouldn't have to touch the
This is still work in progress: before releasing the full version there will be an extensive document Feel free to share those other thoughts you have. I will reply to everything eventually |
@maurei Thanks so much for your response. I want to start off by saying I think the library is great, and I appreciate all the work you guys are doing. If I didn't feel that way, I wouldn't take the time to share these thoughts. I appreciate the clarification on the difference between As for the client serialization - thanks for pointing out the example. In that case, I see you are doing some work in the
Thanks again for all your hard work. I look forward to hearing your thoughts. |
Hi @crgolden, thanks again for the extensive feedback. Generally speaking: all of your feedback (of both your earlier and last post) is valid. Some points require further investigation, other elements could be incorporated straight away. Before addressing each issue individually there is a comment to be made related to most of your points all together. Commenting on why many of these issues haven't been tackles yet: it pretty much boils down to (having limited) time. I've been focussing on issues I encountered myself while trying to use the library for several projects, and these have taken me several months to work on. As of the current pre-release of v4 I've tackled most (not all) of those issues, freeing up time for other improvements. Your feedback is extremely helpful in scoping out what to focus on beyond the current prerelease because your usage is different from mine: you have been probing parts of the framework that I haven't had the opportunity to thoroughly probe yet. Still, the list of feedback is growing faster than I seem to be able to currently process, so I think it would prove helpful to split up this thread into separate and more actionable issues and move on from there. Also, with this I hope to speed up the overall development by promoting other developers contributions apart from my own. I will reply on all of your unaddressed points with a brief comment indicating why I think if it
From there on we should continue the issues in a separate thread. Eventually I will do that gradually when time frees up, but you can do the same while weighing in the relative priority you attach to each issue. |
1. Entity/Resource splits (❓)Having ER splits as a use-case for versioned APIs is an interesting one and I would like to further investigate if ER splits is the only / the best way to go about this when using JANDC. What we need to investigate primarily is the complexity it will (re-)introduce in the codebase. Note that in principle I am a strong proponent of being able to separate concerns through E-R. But
2. The StringId property: Please make this virtual (✅)I don't see any problems with having it virtual. 3. Already addressed (❌)4. Cors/Authentication/Authorization (✅)In general we should allow for full configurability of .net core 3 as much as possible. For standard usage it is nice to have a 5 Immutable properties: (✅)
6 & 7: (De)serialization + domain driven design (❓)I like the idea of domain driven design, but I see a potential problem with extensibility. Eg being able to call 8. Abstractions pattern ✅I am a strong proponent of splitting up JADNC into several smaller NuGet packages. This would also allow for the following
Obviously this is a very big thing to tackle 9. Internal confusion ❓The namespaces right now are still a mess and I completely understand your confusion. This needs tidying up. The same goes for which properties and methods are
10.
|
@maurei Thanks for the terrific responses. I really appreciate you taking the time to address each issue I raised. And I agree that it would be a good idea to separate the split the thread. As far as I'm concerned, this particular issue (the null reference bug) has been addressed, so I will re-close it. I would like to make one more general observation, however. I have seen multiple posts expressing a desire to increase the adoption rate of this library. I agree that would be beneficial - indeed, a concern expressed at my workplace for even using it has been related to the low adoption rate. And additionally, I know may of my observations have been around the issue of versioning. I believe these two are related. This library potentially reshapes the entire public facing contract for each resource it's implemented on, often in a breaking way. As few of us are fortunate enough to live in a greenfield world, this often warrants a new major version of the API. So I think making versioning a first class concern would aid in increasing the adoption rate - especially among more mature organizations. That being said, I was able to address a few of my concerns by adding this to my app.UseWhen(
context => context.GetRequestedApiVersion().MajorVersion == {jadnc_version},
builder => builder.UseJsonApi(false)); As OpenAPI is becoming more mature and adopted in the industry, I think addressing some API explorer concerns would also be beneficial in driving the adoption rate. For instance, as it is now I have to create a mix of To address this (and I believe make the library much more usable), I would propose this architectural change: to make all the controller actions receive I haven't dug into the code too much, but I'm guessing this would remove some complexity in the middleware. It would also make API explorers like Swagger work out-of-the-box with no filter madness. Thanks again and have a great holiday. |
I think that is a legitimate observation and would be willing to prioritise development resources to this cause. At the same time at my workspace the demand for such feature is limited and for that reason it would beneficial for the framework if people were to be involved that have an in-depth overview of what precisely is required from JADNC to properly support versioning of APIs. That being said, elaborating on the following
The up-side of the low adoption rate is being able to easily influence the direction of the framework. I'm guessing my hint will be clear by now, having you guys contribute to this development would be more than welcome 👍🚀
This is an interesting approach and definitely something we could investigate. First question that comes up in my mind is the following. The |
@crgolden Chris, thanks for your effort to indicate problems with JADNC, a lot of points are valid. |
Description
When an id is not found on a
GetAsync(id)
request, the controller properly returns aNotFoundResult
. However, this seems to break after that and what is actually returned to the client is aNullReferenceException
.Most concerning from a security standpoint is that the stack trace is returned.
Reference: Improper Error Handling
I updated my sample repo with a simple integration test (
NotFound
) that reproduces this behavior. Please advise if I am missing something....
Environment
The text was updated successfully, but these errors were encountered: