Dancer2 0.166000 - 404 Behaviour Change
Has something changed (deliberately!) in the handling of 404 errors between Dancer2 0.165000 and 0.166000? I have a project that is being tested with Travis-CI. The last test that used 0.165000[1] worked fine, but (after a few weeks not working on the project) the next test run used 0.166000[2] and failed on two tests[3] that generate 404 errors. I updated my local copy of Dancer2 and found I could reproduce the problem in the web app. The problem seemed to be that the app was always trying to use views/404.tt (which didn't exist) instead of using public/404.html if it can't find views/404.tt - which was the old behaviour. Looking through the Changes file, it seems that it might be related to this: * GH #1093, 1095: Use a dynamic TT2 INCLUDE_PATH to allow relative views with relative includes; fixing regression introduced by #1037. (Russell Jenkins) But I haven't had time to investigate further. I've fixed the problem by adding a views/404.tt file to the project. But I think that's just a workaround. I plan to dig a little deeper into the problem later in the week, but I thought I'd mention it here first in case anyone had any insights that could save me some time. Cheers, Dave... [1] https://travis-ci.org/davorg/lystyng/builds/97884180 [2] https://travis-ci.org/davorg/lystyng/builds/102335005 [3] https://github.com/davorg/lystyng/blob/master/t/004_public_urls.t
Quoting Dave Cross <dave@dave.org.uk>:
I plan to dig a little deeper into the problem later in the week,
Couldn't resist a quick look, and I think I've found the problem. It's this commit. https://github.com/PerlDancer/Dancer2/commit/32935dbc7bc1369047c4af572b1e04f... It switches from using "-f" to see if the template exists, to using $engine->pathname_exists. This changes the behaviour as pathname_exists() uses Template::Context::template(), which dies if the template can't be found. So the call to pathname_exists() probably needs to be in a try/catch block. I'll see if I can come up with a failing test and a patch. hth, Dave...
-----Original Message----- From: dancer-users [mailto:dancer-users-bounces@dancer.pm] On Behalf Of Dave Cross Sent: 20 January 2016 14:08 To: Perl Dancer users mailing list <dancer-users@dancer.pm> Subject: Re: [dancer-users] Dancer2 0.166000 - 404 Behaviour Change
Quoting Dave Cross <dave@dave.org.uk>:
I plan to dig a little deeper into the problem later in the week,
Couldn't resist a quick look, and I think I've found the problem. It's this commit.
https://github.com/PerlDancer/Dancer2/commit/32935dbc7bc1369047c4af572 b1e04f34fb08fb8
It switches from using "-f" to see if the template exists, to using $engine-
pathname_exists. This changes the behaviour as pathname_exists() uses Template::Context::template(), which dies if the template can't be found.
So the call to pathname_exists() probably needs to be in a try/catch block.
I'll see if I can come up with a failing test and a patch.
hth,
Dave...
_______________________________________________
Yes we had this too this morning - turned out to be a rogue absolute path to a view. Changing to relative fixed it Z
Quoting Dave Cross <dave@dave.org.uk>:
I'll see if I can come up with a failing test and a patch.
In the meantime, to see the problem. * Create a new Dancer2 app - $ dancer2 gen -a Foo * Edit config.yml to switch to templating engine to TT * Start the app - $ plackup bin/app.psgi * Visit http://localhost:5000/not-there - See the following: Internal Server Error file error - 404.tt: not found Cheers, Dave...
Quoting Dave Cross <dave@dave.org.uk>:
Has something changed (deliberately!) in the handling of 404 errors between Dancer2 0.165000 and 0.166000?
I have a project that is being tested with Travis-CI. The last test that used 0.165000[1] worked fine, but (after a few weeks not working on the project) the next test run used 0.166000[2] and failed on two tests[3] that generate 404 errors.
I updated my local copy of Dancer2 and found I could reproduce the problem in the web app. The problem seemed to be that the app was always trying to use views/404.tt (which didn't exist) instead of using public/404.html if it can't find views/404.tt - which was the old behaviour.
Looking through the Changes file, it seems that it might be related to this:
* GH #1093, 1095: Use a dynamic TT2 INCLUDE_PATH to allow relative views with relative includes; fixing regression introduced by #1037. (Russell Jenkins)
But I haven't had time to investigate further.
I've fixed the problem by adding a views/404.tt file to the project. But I think that's just a workaround.
I plan to dig a little deeper into the problem later in the week, but I thought I'd mention it here first in case anyone had any insights that could save me some time.
Update: Looks like 0.166001 (released this morning) fixes this problem. Dave...
[1] https://travis-ci.org/davorg/lystyng/builds/97884180 [2] https://travis-ci.org/davorg/lystyng/builds/102335005 [3] https://github.com/davorg/lystyng/blob/master/t/004_public_urls.t
This was a pressed week on a personal level for me, so I apologize for the late response to this. Luckily, the project has much more responsible people than I involved in it and it was discovered, analyzed, and fixed quickly. I was then kicked (thanks, Rusty and Matt) to push a release ASAP. We sincerely apologize for the mess this caused people, and appreciate the help with informing us and others on the problem and the debugging information on what's causing this. We appreciate it deeply. :) On Fri, Jan 22, 2016 at 2:26 PM, Dave Cross <dave@dave.org.uk> wrote:
Quoting Dave Cross <dave@dave.org.uk>:
Has something changed (deliberately!) in the handling of 404 errors between Dancer2 0.165000 and 0.166000?
I have a project that is being tested with Travis-CI. The last test that used 0.165000[1] worked fine, but (after a few weeks not working on the project) the next test run used 0.166000[2] and failed on two tests[3] that generate 404 errors.
I updated my local copy of Dancer2 and found I could reproduce the problem in the web app. The problem seemed to be that the app was always trying to use views/404.tt (which didn't exist) instead of using public/404.html if it can't find views/404.tt - which was the old behaviour.
Looking through the Changes file, it seems that it might be related to this:
* GH #1093, 1095: Use a dynamic TT2 INCLUDE_PATH to allow relative views with relative includes; fixing regression introduced by #1037. (Russell Jenkins)
But I haven't had time to investigate further.
I've fixed the problem by adding a views/404.tt file to the project. But I think that's just a workaround.
I plan to dig a little deeper into the problem later in the week, but I thought I'd mention it here first in case anyone had any insights that could save me some time.
Update: Looks like 0.166001 (released this morning) fixes this problem.
Dave...
[1] https://travis-ci.org/davorg/lystyng/builds/97884180 [2] https://travis-ci.org/davorg/lystyng/builds/102335005 [3] https://github.com/davorg/lystyng/blob/master/t/004_public_urls.t
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
participants (3)
-
Dave Cross -
Sawyer X -
Zahir Lalani