alphagov / asset-manager

Manages uploaded assets (images, PDFs etc.) for applications on GOV.UK
https://docs.publishing.service.gov.uk/apps/asset-manager.html
MIT License
9 stars 9 forks source link

ActionController::UrlGenerationError exceptions in Whitehall #371

Open floehopper opened 6 years ago

floehopper commented 6 years ago

I suspect these exceptions in the Whitehall app might be related to alphagov/whitehall#3627.

floehopper commented 6 years ago

Prior to alphagov/whitehall#3627, a request for this URL would've generated a 404 Not Found response from PublicUploadsController#fail, because no file with the specified path/filename exists in either the clean or incoming directories.

The URL itself is somewhat mysterious, because it contains Unicode non-breaking spaces (%C2A0) rather than underscore characters and a newline character (%0A) in the filename. This makes me suspicious that the URL was manually generated, perhaps by being copied and pasted from a document which resulted in the unhelpful characters. Unfortunately the HTTP_REFERER request header is not set and so it's hard to work out the origin of the request.

The ActionController::UrlGenerationError exception is the result of the following:

I'm not entirely sure what to do about this problem, but I am confident that it's not a serious issue because of the following:

Thus I really don't think this is a serious problem and am happy to leave it until I can discuss it with @chrisroos & @chrislo on their return from holiday.

floehopper commented 6 years ago

This exception has just happened a bunch more times...

Staging

Production

They all look as if they relate to requests with a newline in the asset path. I wonder if there's some systematic problem - could Govspeak be accidentally generating URL paths including newlines?

@chrislo, @chrisroos: Do you have any thoughts on this?

floehopper commented 6 years ago

I'm no longer actively investigating this, so I'm going to un-assign myself.

floehopper commented 6 years ago

This has happened again: https://sentry.io/govuk/app-whitehall/issues/434107507/

chrisroos commented 6 years ago

We've seen some more of these exceptions in the past couple of days. Searching Sentry for ActionController::UrlGenerationError appears to show all of these exceptions.

The following paths are all resulting in these exceptions:

As @floehopper has already suggested, my best guess is that someone has pasted these links into a document and then accidentally inserted newlines (%0A) in the URLs.