Print languages: backend-neutral codes from the CMS, malformed Accept-Language degrades instead of throwing - #6969
Merged
Merged
Conversation
…Accept-Language degrades instead of throwing
The S3 CMS names child folders with their trailing separator (en/), so
CmsStore.listLanguages served slash-suffixed language codes; the print
dialog offered them and pinned the pick as Accept-Language, and
Locale.LanguageRange.parse("en/") then threw out of
UserFacade.getLanguage - every localized repository read in the print
feeder answered 500 on S3-backed deployments.
CmsStore now strips the separator so the language CODE contract does not
depend on the CMS backend, and UserFacade.getLanguage treats a malformed
client-controlled header as "no preference" (warn + empty) instead of
propagating IllegalArgumentException.
Fixes #6967
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
| // The header is client-controlled: a malformed value must degrade to "no language | ||
| // preference", never turn every localized read on this request into a 500. | ||
| if (logger.isWarnEnabled()) { | ||
| logger.warn("Malformed Accept-Language header [{}] - ignoring it", language); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #6967 — two halves, both needed:
CmsStore.listLanguagesstrips the trailing path separator the S3 CMS keeps on child folder names (CmisS3Folder.getName()→en/), soGET /services/print/{entity}/languagesserves the same clean codes on every CMS backend.UserFacade.getLanguagecatchesIllegalArgumentExceptionfromLocale.LanguageRange.parse— the header is client-controlled, and a malformed value must degrade to "no language preference" (warn + empty) rather than turn every localized repository read on the request into a 500.Observed in production-shaped staging (S3 CMS, 14.36.0): Print → any language →
SalesInvoicePrintFeeder#feed threw: range=en/.🤖 Generated with Claude Code