Page MenuHomePhabricator

Errors when generating thumbnails should result in HTTP 400, not HTTP 500
Closed, ResolvedPublic

Description

looking at the sampled logs on erbium it seems we're throwing http 500s regularly when generating thumbs, most errors seem due to the wrong size being requested that would result in upscaling the image.

I'm sure this is known already but it'd seem more logical for such errors to return a 400 to the client since it isn't strictly the server's fault, what do you think?

erbium:~$ grep  miss/50 /a/log/webrequest/sampled-1000.tsv.log | uniq -f2 -w16 -c | awk '{print $1 " " $4 " " $9 " " $10}'
6 2015-02-03T06:26:29 GET http://upload.wikimedia.org/wikipedia/el/thumb/9/9e/%CE%A0%CE%B1%CF%81%CE%B1%CE%BC%CE%B5%CE%BB%CE%B7%CE%BC%CE%AD%CE%BD%CE%B7_%CE%9F%CF%85%CF%81%CE%B9%CE%BA%CE%AE_%CE%B1%CF%81%CE%B8%CF%81%CE%AF%CF%84%CE%B9%CF%82_%CE%A7%CE%B5%CF%81%CE%B9%CF%8E%CE%BD.JPG/1032px-%CE%A0%CE%B1%CF%81%CE%B1%CE%BC%CE%B5%CE%BB%CE%B7%CE%BC%CE%AD%CE%BD%CE%B7_%CE%9F%CF%85%CF%81%CE%B9%CE%BA%CE%AE_%CE%B1%CF%81%CE%B8%CF%81%CE%AF%CF%84%CE%B9%CF%82_%CE%A7%CE%B5%CF%81%CE%B9%CF%8E%CE%BD.JPG
19 2015-02-03T06:30:14 GET http://upload.wikimedia.org/wikipedia/commons/thumb/4/4a/Commons-logo.svg/36px-Commons-logo.svg.png%202x"%20data-file-width="1024"%20data-file-height="1376"%20/></a>%20<b><span%20class="plainlinks"><a%20class="external%20text"%20href="http:/lookup-api.apple.com.edgesuite.net/commons.wikimedia.org/wiki/?uselang=it">Commons</a></span></b>
7 2015-02-03T06:40:19 GET http://upload.wikimedia.org/wikipedia/en/thumb/6/6f/Vathikuchi.jpg/402px-Vathikuchi.jpg
10 2015-02-03T06:51:42 GET http://upload.wikimedia.org/wikipedia/commons/thumb/8/86/Valencia01_11-2-03.JPG/794px-Valencia01_11-2-03.JPG
7 2015-02-03T07:00:14 GET http://upload.wikimedia.org/wikipedia/en/thumb/9/9e/Koli_tree_near_Panamaram_fort_site.JPG/1024px-Koli_tree_near_Panamaram_fort_site.JPG
13 2015-02-03T07:10:25 GET http://upload.wikimedia.org/wikipedia/ja/thumb/9/95/%E3%83%88%E3%82%B3%E3%82%B8%E3%83%A9%E3%83%9F_%E6%8A%9C%E3%81%91%E6%AE%BB.JPG/640px-%E3%83%88%E3%82%B3%E3%82%B8%E3%83%A9%E3%83%9F_%E6%8A%9C%E3%81%91%E6%AE%BB.JPG
14 2015-02-03T07:21:22 GET http://upload.wikimedia.org/wikipedia/commons/thumb/6/61/Opentail_g.svg/8px-Opentail_g.svg.png"%20width="8"%20height="14"%20srcset="http:/lookup-api.apple.com.edgesuite.net/upload.wikimedia.org/wikipedia/commons/thumb/6/61/Opentail_g.svg/12px-Opentail_g.svg.png%201.5x,%20http:/lookup-api.apple.com.edgesuite.net/upload.wikimedia.org/wikipedia/commons/thumb/6/61/Opentail_g.svg/16px-Opentail_g.svg.png%202x"%20data-file-width="115"%20data-file-height="196"%20/></a>
10 2015-02-03T07:30:50 GET http://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Flag_of_the_People%27s_Republic_of_China.svg/35px-Flag_of_the_People%27s_Republic_of_China.svg.png%201.5x,%20http:/lookup-api.apple.com.edgesuite.net/upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Flag_of_the_People%27s_Republic_of_China.svg/45px-Flag_of_the_People%27s_Republic_of_China.svg.png%202x"%20data-file-width="900"%20data-file-height="600"%20/>&
11 2015-02-03T07:40:05 GET http://upload.wikimedia.org/wikipedia/commons/thumb/2/23/Casino_slots2.jpg/
18 2015-02-03T07:50:32 GET http://upload.wikimedia.org/wikipedia/commons/thumb/c/c9/Laos.Visa.JPG/1005px-Laos.Visa.JPG
15 2015-02-03T08:00:36 GET http://upload.wikimedia.org/wikipedia/commons/thumb/a/a0/Fairytale_bookmark_silver.svg/21px-Fairytale_bookmark_silver.svg.png%201.5x,%20http:/lookup-api.apple.com.edgesuite.net/upload.wikimedia.org/wikipedia/commons/thumb/a/a0/Fairytale_bookmark_silver.svg/28px-Fairytale_bookmark_silver.svg.png%202x"%20data-file-width="100"%20data-file-height="100"%20/></span>%20<i><a%20href="/wiki/L%27Illusion_comique_(t%C3%A9l%C3%A9film)"%20title="L
9 2015-02-03T08:11:23 GET http://upload.wikimedia.org/wikipedia/commons/thumb/8/88/WIN31SOD.JPG/816px-WIN31SOD.JPG
11 2015-02-03T08:20:25 GET http://upload.wikimedia.org/wikipedia/commons/thumb/9/9d/Warszawa%2C_Pa%C5%82ac_Kultury_i_Nauki_-_26.11.2009_r..JPG/728px-Warszawa%2C_Pa%C5%82ac_Kultury_i_Nauki_-_26.11.2009_r..JPG
15 2015-02-03T08:30:00 GET http://upload.wikimedia.org/wikipedia/commons/thumb/6/66/Torre_de_Belem_1.JPG/1024px-Torre_de_Belem_1.JPG
20 2015-02-03T08:40:03 GET http://upload.wikimedia.org/wikipedia/commons/thumb/0/0e/TRON_9-9145.gif/16px-TRON_9-9145.gif
22 2015-02-03T08:50:08 GET http://it.wikipedia.org/w/index.php?title=Speciale:Captcha/image&wpCaptchaId=160756292
18 2015-02-03T09:01:52 GET http://upload.wikimedia.org/wikipedia/en/thumb/6/6f/Vathikuchi.jpg/402px-Vathikuchi.jpg
23 2015-02-03T09:11:18 GET http://upload.wikimedia.org/wikipedia/commons/thumb/b/b3/2005_Pebble_Beach_Concours_Bertone.PNG/466px-2005_Pebble_Beach_Concours_Bertone.PNG
19 2015-02-03T09:20:28 GET http://upload.wikimedia.org/wikipedia/en/thumb/4/49/ImamRezaHospital.JPG/800px-ImamRezaHospital.JPG
10 2015-02-03T09:30:18 GET http://upload.wikimedia.org/wikipedia/en/thumb/2/2e/Wine_TV.PNG/96px-Wine_TV.PNG

Event Timeline

fgiunchedi raised the priority of this task from to Needs Triage.
fgiunchedi updated the task description. (Show Details)
fgiunchedi added a project: Multimedia.
fgiunchedi added a subscriber: fgiunchedi.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptFeb 3 2015, 9:40 AM
Tgr renamed this task from recurring http 500 errors when generating thumbnails to Errors when generating thumbnails should result in HTTP 400, not HTTP 500.Feb 4 2015, 11:10 PM
Tgr set Security to None.
Tgr added a subscriber: Tgr.Feb 4 2015, 11:13 PM

See also T75935 and T74328.

Tgr added a comment.Feb 4 2015, 11:40 PM

I'm sure this is known already but it'd seem more logical for such errors to return a 400 to the client since it isn't strictly the server's fault, what do you think?

There are three kinds of errors in the logs you pasted:

  1. requesting a captcha with a bogus id (link) - this is probably via the FancyCaptcha extension and should be a separate bug
  2. requesting a bigger image (or, in some cases, the same size) as the source ($thumb->fileIsSource() check in thumb.php)
  3. garbage in query string - wfThumbError(400, ...) is called in thumb.php but the error still ends up to be 500.
gerritbot added a subscriber: gerritbot.

Change 188710 had a related patch set uploaded (by Gergő Tisza):
Make thumb.php respond with HTTP 400 (not 500) on invalid parameters

https://gerrit.wikimedia.org/r/188710

Patch-For-Review

Tgr moved this task from Untriaged to Needs code review on the Multimedia board.Feb 5 2015, 12:57 AM
In T88412#1016386, @Tgr wrote:

I'm sure this is known already but it'd seem more logical for such errors to return a 400 to the client since it isn't strictly the server's fault, what do you think?

There are three kinds of errors in the logs you pasted:

indeed that was conflating several issues, I failed to point out the emphasis which was on the number of hits per 10-min bucket. The log above is also really a summary and there might be more failure cases hidden.

  1. requesting a captcha with a bogus id (link) - this is probably via the FancyCaptcha extension and should be a separate bug
  2. requesting a bigger image (or, in some cases, the same size) as the source ($thumb->fileIsSource() check in thumb.php)
  3. garbage in query string - wfThumbError(400, ...) is called in thumb.php but the error still ends up to be 500.

what's the best phab project to report #1? I haven't paid much attention to other issues beside #2 to be honest since those were the majority afaict

Tgr added a comment.EditedFeb 5 2015, 7:16 PM

what's the best phab project to report #1? I haven't paid much attention to other issues beside #2 to be honest since those were the majority afaict

#MediaWiki-extensions-ConfirmEdit , I think.

Tgr claimed this task.Feb 6 2015, 3:02 AM

Change 188710 merged by jenkins-bot:
Make thumb.php respond with HTTP 400 (not 500) on invalid parameters

https://gerrit.wikimedia.org/r/188710

Gilles added a subscriber: Gilles.Feb 11 2015, 12:54 PM

Should we also change the 500 happening when people request a larger (or equal) size than the original to a 400?

Gilles triaged this task as Medium priority.Feb 11 2015, 12:55 PM
Gilles moved this task from Ready for testing to Next up on the Multimedia board.
Tgr added a comment.Feb 11 2015, 6:16 PM

Should we also change the 500 happening when people request a larger (or equal) size than the original to a 400?

I think that's covered by line 334 of the patch.

Gilles closed this task as Resolved.Feb 11 2015, 7:11 PM

Great! I missed that. Sounds like this is completely done, then.