fix language validation & usage in interactive flows #657
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses 2 bugs in Polaris:
lang
parameter values are not supportedSecondary Tag Support
Polaris validates the
lang
parameter values sent in requests by matching them against the anchor'sLANGUAGES
settings object. However, this strict matching causes Polaris to reject requests when a secondary language tag is included in thelang
value.For example, if a user wants to read Brazilian Portuguese and specifies
pt-br
as thelang
value in a request to initiate a transaction, Polaris will reject the request with a 400 ifsettings.LANGUAGES
only contains an entry forpt
.This would not occur if the client specified their desired language using the
Accept-Language
header, which is a case handled by Django directly.Polaris should use the same validation logic as Django.
SEP-24 Interactive Flow
Additionally, the SEP-24 specification states that the value passed in a
POST /transactions/deposit/interactive
request should be used for the interactive flow, but Polaris does not currently propagate this information to its interactive flow.When a client specifies the
lang
parameter via this request, Polaris should add a query parameter to the interactive URL returned in the response containing the same value passed vialang
. When the URL is used to open the interactive flow, Polaris will set the content of the interactive flow to use the specified language for the entire user web session.