Skip to content
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

Throwing NotFoundException results in 500 error page #6466

Open
toebu opened this issue Jun 3, 2024 · 1 comment
Open

Throwing NotFoundException results in 500 error page #6466

toebu opened this issue Jun 3, 2024 · 1 comment

Comments

@toebu
Copy link
Contributor

toebu commented Jun 3, 2024

Description

When throwing a Kirby\Exception\NotFoundException, an error page is rendered as if an internal server error would have happened with an http status code of 500.

Expected behavior
Render the 404 page, with a 404 http status code.

To reproduce

  1. Take the Kirby Starter Kit
  2. Add the following to the config:
    'routes' => [
        [
            'pattern' => 'test',
            'action'  => function () {
                throw new NotFoundException();
            }
        ]
    ]
  1. Go to http://localhost/test

Or alternatively

  1. Take the Kirby Starter Kit
  2. Edit site/controllers/notes.php to include throw new NotFoundException(); right at the beginning of the returned function.
  3. Go to http://localhost/notes

Or even worse

  1. Take the Kirby Starter Kit
  2. Go for example to http://localhost/media/pages/photography/trees/1

In this last case, the NotFoundException is thrown from Kirby internally with the message "The thumbnail configuration could not be found".

I'm not sure if I should report a separate bug, because you can basically enter anything starting with http://localhost/media/pages/photography/trees/... and it will log a NotFoundException, even though it should just render a normal 404 page without logging anything.

Your setup

Kirby Version
Latest version 4.2.0

  • OS: Linux
  • Browser: Firefox
  • Version: 126
@afbora
Copy link
Member

afbora commented Jun 3, 2024

About media link issue is solved in #6446 (will be available 4.3.0)

I was also realized that NotFoundException returns 500 http header instead 404 in that issue. I'm not sure this is bug or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants