Page MenuHomePhabricator

bad request when attempting to download pdfs
Closed, ResolvedPublicPRODUCTION ERROR

Description

Steps to replicate the issue (include links if applicable):

What happens?:

  • FAIL: errors out with message "Bad request"

What should have happened instead?:

  • The download should be prompted

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):
WMF Production

Other information (browser name/version, screenshots, etc.):

Event Timeline

Restricted Application changed the subtype of this task from "Bug Report" to "Production Error". · View Herald TranscriptSep 29 2025, 6:56 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Multiple VRT tickets opened from customers on this today

2025092910009213
2025092910008876

matmarex subscribed.

This is because https://en.wikipedia.org/api/rest_v1/page/pdf/ returns "Bad Request" for every page, e.g. https://en.wikipedia.org/api/rest_v1/page/pdf/United_States_Post_Office_(Forest_Hills%2C_Queens).

Both codfw and eqiad deployments return 200 for the given page:

curl -v -o /dev/null "https://proton.svc.codfw.wmnet:4030/en.wikipedia.org/v1/pdf/United_States_Post_Office_(Forest_Hills%2C_Queens)/A4/desktop" 2>&1 | grep 200
< HTTP/1.1 200 OK

jgiannelos@deploy2002:~$ curl -v -o /dev/null "https://proton.svc.eqiad.wmnet:4030/en.wikipedia.org/v1/pdf/United_States_Post_Office_(Forest_Hills%2C_Queens)/A4/desktop" 2>&1 | grep 200
< HTTP/1.1 200 OK

When I request the same title from rest-gateway directly also works:

curl -v -o /dev/null "https://rest-gateway.discovery.wmnet:4113/en.wikipedia.org/v1/page/pdf/United_States_Post_Office_(Forest_Hills%2C_Queens)/a4/desktop" 2>&1 | grep 200
< HTTP/1.1 200 OK

The problem is that rest gateway is not allowing a default path with no /{type=A4}/{format=Desktop} suffix.
For example this request is succesful (using the default params):

curl -v -o /dev/null "https://proton.svc.eqiad.wmnet:4030/en.wikipedia.org/v1/pdf/Dog" 2>&1 | grep 200
< HTTP/1.1 200 OK

From edge both these requests work:

 nemo@wmf3428 > curl -v -o /dev/null 'https://en.wikipedia.org/api/rest_v1/page/pdf/Dog/a4' 2>&1 | grep 200
< HTTP/2 200
 nemo@wmf3428 > curl -v -o /dev/null 'https://en.wikipedia.org/api/rest_v1/page/pdf/Dog/a4/desktop' 2>&1 | grep 200
< HTTP/2 200

I think there must be something wrong in the first rule of rest-gateway regarding pdf:
https://gerrit.wikimedia.org/g/operations/deployment-charts/+/b232ae82fb7b3751f4e994aed8fa3d7572acd368/helmfile.d/services/rest-gateway/values.yaml#141

Change #1192507 had a related patch set uploaded (by Jgiannelos; author: Jgiannelos):

[operations/deployment-charts@master] rest-gateway: Fix typo in URL rewrite causing breakage on PDF downloads

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

Change #1192507 merged by jenkins-bot:

[operations/deployment-charts@master] rest-gateway: Fix typo in URL rewrite causing breakage on PDF downloads

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

Clement_Goubert subscribed.
cgoubert@deploy2002:~$ for svc in staging.svc.eqiad rest-gateway.svc.eqiad rest-gateway.svc.codfw; do curl -v -k -H 'Host: en.wikipedia.org' https://$svc.wmnet:4113/en.wikipedia.org/v1/page/pdf/Foo -o /dev/null 2>&1 | grep 200; done
< HTTP/1.1 200 OK
< HTTP/1.1 200 OK
< HTTP/1.1 200 OK
cgoubert@deploy2002:~$ for svc in staging.svc.eqiad rest-gateway.svc.eqiad rest-gateway.svc.codfw; do curl -v -k -H 'Host: en.wikipedia.org' https://$svc.wmnet:4113/en.wikipedia.org/v1/page/pdf/Foo/a4 -o /dev/null 2>&1 | grep 200; done
< HTTP/1.1 200 OK
< HTTP/1.1 200 OK
< HTTP/1.1 200 OK
cgoubert@deploy2002:~$ for svc in staging.svc.eqiad rest-gateway.svc.eqiad rest-gateway.svc.codfw; do curl -v -k -H 'Host: en.wikipedia.org' https://$svc.wmnet:4113/en.wikipedia.org/v1/page/pdf/Foo/a4/desktop -o /dev/null 2>&1 | grep 200; done
< HTTP/1.1 200 OK
< HTTP/1.1 200 OK
< HTTP/1.1 200 OK

Fix deployed, thanks @Jgiannelos for the patch.

I broke this in yesterday in this patch for T405368: Execute test plan for rest gateway rerouting for rest.php requests and report findings and didn't notice, I'm sorry about that, I will add additional tests to our deployment to lower the likelihood of this happening again.

Aklapper edited projects, added Regression; removed Patch-For-Review.