-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Normalize 4xx responses for invalid plugins/actions/assets and quiet their logging #23891
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
base: 5.x-dev
Are you sure you want to change the base?
Conversation
e9a83d0 to
85a28c1
Compare
| if ($e instanceof HttpCodeException && $e->getCode() >= 400 && $e->getCode() < 500) { | ||
| StaticContainer::get(LoggerInterface::class)->debug('Uncaught exception in API: {exception}', [ | ||
| 'exception' => $e, | ||
| 'ignoreInScreenWriter' => true, | ||
| ]); | ||
| } else { | ||
| StaticContainer::get(LoggerInterface::class)->error('Uncaught exception in API: {exception}', [ | ||
| 'exception' => $e, | ||
| 'ignoreInScreenWriter' => true, | ||
| ]); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there be a difference in error handling/messaging between those two cases?
Same for other places the if/else has appeared.
|
|
||
| if (!$foundChunk) { | ||
| throw new \Exception("Could not find chunk {$this->requestedChunk}"); | ||
| throw new BadRequestException("Could not find chunk {$this->requestedChunk}", 404); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the exception class checked anywhere? Or can use a more generic one? Or treat the request as a 400 instead of a 404?
"Bad Request" feels wrong when setting a 404 specifically because the name implies a 400 🤔
As that is also happening in the ControllerResolver, maybe we should add a ThingNotFoundException for those 404s?
| $this->chunkCount = $chunkCount; | ||
|
|
||
| if (!$this->loadIndividually && (!is_int($chunkCount) || $chunkCount <= 0)) { | ||
| throw new \Exception("Invalid chunk count: $chunkCount"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this now be a BadRequestException?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it seems that the chunkCount parameter isn't provided by the request at all. The method parameter is unused, so it should use the default.
…debug level in that case
Description
404, missing chunks return 404, missing plugins return 404, deactivated plugins return 403.
action, 404 missing asset chunk) and for plugin activation checks (404 missing plugin, 403 deactivated) plus missing
chunk error in the asset fetcher.
Checklist
Review