warehouse
warehouse copied to clipboard
`request.accept_language.best_match` will be deprecated
Per https://github.com/Pylons/webob/blob/39d5af3c797e7b867f152c2e8c979de42d029403/src/webob/acceptparse.py#L4358-L4374:
This is currently maintained for backward compatibility, and will be deprecated in the future.
We may want to replace this with request.accept_language.lookup instead.
A potential issue is that at https://github.com/pypi/infra/blob/d5374e6e92f5a09729d649a0a587935d19f2d76f/terraform/warehouse/vcl/main.vcl#L168 we use the language_lookup function, this might behave slightly differently than best_match or slightly differently than lookup (unsure). The former might result in a current bug, and the latter might produce a bug if we use lookup instead, in which the locale we negotiate differs from what we set in VCL.
Additionally, the locale negotiation on the backend might be unnecessary in most cases: if we just use the PyPI-Locale header set by Fastly (assuming this is set for all requests, cached &. uncached) then it should be sufficient.
However, we have some endpoints (like upload.pypi.org) that bypass Fastly and locale negotiation needs to happen on the backend. In those cases, it should fall back to what we have now.
Regardless, all translated views should write PyPI-Locale on the response to the singular negotiated locale value of the content served, ensure that we don't add mis-translated cache entries.
Additionally, VCL needs to ensure that any value it sets to PyPI-Locale is a known locale, otherwise this can be set to any arbitrary value.
Related, see https://github.com/Pylons/webob/pull/460 for work gone in to reimplement best_match