Route – Return empty array

I have the following route:

    [
      'pattern' => '1234',
      'action' => function() {
        $cacheFile = '/lineups/testing.json';

        if (F::exists($cacheFile)) {
          return Json::decode(F::read($cacheFile));
        } 

        return [];
      }
    ]

and I want to return an empty array, if the file dosen’t exist. But somehow I get a 404 error and it shows the error page.
Also an empty string return a 404. But as soon as I return an array with at least 1 item or a string which is not empty, it works as expected.

I’m not sure if this is by design or if its a bug?

{
  "info": {
    "kirby": "4.3.0",
    "php": "8.2.10",
    "server": "nginx/1.25.2",
    "license": "Unregistered",
    "languages": []
  }
}

(I don’t know why it shows php82. I’m using herd with only php8.3 installed.)

It is by design. We do an empty() check in PHP and both your described returns would be caught in this check:

You can return

			    return new Response('{}', 'application/json', 200);//json_decode($json);