FIX return 404 instead of 500 for invalid model class, fixes #570#1757
FIX return 404 instead of 500 for invalid model class, fixes #570#1757xini wants to merge 1 commit intosilverstripe:2.2from
Conversation
|
I'm not convinced this is desirable. As @dhensby points out in the issue, the existing error is useful for debugging. At a minimum I'd want to keep throwing the exception in dev mode. Maybe we want a 404 in live and maybe test mode? Though I'd want @silverstripe/core-team to weigh in with their thoughts. |
|
In the meantime, please retarget this to the |
|
I'd leave it as is. The fact the model doesn't exist would still be exposed, just with a different HTTP code. It might be more confusing, as a developer, to get 404 instead of 500. |
|
I disagree. When an URL is incorrect, like https://www.silverstripe.org/foo, you expect a 404. This should also be the case for a model admin URL like https://www.silverstripe.org/admin/my-admin/foo. There is no logical reason for this to be a 5xx response and not a 404. |
5493a28 to
20ab93f
Compare
Description
When a ModelAdmin is called with a model that doesn’t exist, the fact that it doesn’t exist is exposed in a 500 error if the site is in dev.
Affected: silverstripe/silverstripe-admin 1 and 2 (Silverstripe 4 and 5)
In the init() method of ModelAdmin (https://github.com/silverstripe/silverstripe-admin/blob/2/code/ModelAdmin.php#L165) a RuntimeException is thrown including the class information. This is also the case when there is no user logged into the CMS.
This is the case for v1 and v2 of this module!
Issues
Pull request checklist