Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@sgiehl
Copy link
Member

@sgiehl sgiehl commented Dec 11, 2025

Description

  • Map client-side faults to consistent 4xx responses: missing/invalid API params return 400, invalid actions return
    404, missing chunks return 404, missing plugins return 404, deactivated plugins return 403.
  • Silence noisy error logging for 4xx-only failures by tagging these paths as HttpCodeException and downgrading log
  • System/integration tests added for HTTP status expectations (400 missing param, 404 missing plugin, 404 invalid
    action, 404 missing asset chunk) and for plugin activation checks (404 missing plugin, 403 deactivated) plus missing
    chunk error in the asset fetcher.

Checklist

  • [✔] I have understood, reviewed, and tested all AI outputs before use
  • [✔] All AI instructions respect security, IP, and privacy rules

Review

@sgiehl sgiehl added this to the 5.7.0 milestone Dec 11, 2025
@sgiehl sgiehl requested a review from a team December 11, 2025 11:17
@sgiehl sgiehl force-pushed the dev-19666 branch 3 times, most recently from e9a83d0 to 85a28c1 Compare December 11, 2025 16:54
Comment on lines 287 to 297
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,
]);
}
Copy link
Member

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);
Copy link
Member

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");
Copy link
Member

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?

Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants