Skip to content

[FIX] manifestEnhancer: Only use valid files for supportedLocales #1080

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 16, 2025

Conversation

matz3
Copy link
Member

@matz3 matz3 commented Sep 5, 2024

This fixes two problems that could have occurred:

A properties file with an invalid locale was still taken into the list of supported locales, which then caused a runtime exception in the ResourceBundle as it validates the input.

Another problem was that properties files could have a valid name according to BCP47, but the file won't be ever requested with that name.
This is due to the fact that the ResourceBundle does use the legacy Java locale format (using underscores instead of dashes) for the request URL.

In both cases, the properties file is now ignored and no entry for the supportedLocales is created.

Only locales that are valid according to the legacy Java locale format are considered.
However, there is one special case: sr_Latn is also requested by the UI5 runtime, although it contains a BCP47 script, which is not valid according to the legacy Java locale format.

@matz3 matz3 added the bug label Sep 5, 2024
@matz3 matz3 requested a review from a team September 5, 2024 07:37
if (isValidPropertiesFilenameLocale(locale)) {
supportedLocales.push(locale);
} else {
log.verbose(`Skipping invalid locale '${locale}' for bundle '${i18nBundleUrl}'`);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still open: What should happen in this case? Maybe rather an warning or even error log?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decision: Log a warning and explain in commit message that the warning can be suppressed by manually maintaining the "supportedLocales".

Copy link
Member Author

@matz3 matz3 Sep 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be checked: Built-in handling of private extensions at runtime (1Q, 2Q, 3Q).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning added via 11ab19f

To be checked: Built-in handling of private extensions at runtime (1Q, 2Q, 3Q).

This just turned out to be a confusion based on a wrong comment / commit message. It referred to variants, but actually it was supposed to be extensions.

Extensions are not considered by the runtime code at all (i.e. can't appear in requests).
Private use is checked for the special SAP supportability locales, but the resulting request does not include an extension or private use section but will rather be e.g. en_US_saptrc (where saptrc is a variant).

@coveralls
Copy link

coveralls commented Sep 5, 2024

Coverage Status

coverage: 94.946% (+0.04%) from 94.911%
when pulling 0a54eb8 on fix-manifestEnhancer-invalid-locale
into 4245546 on main.

@matz3 matz3 force-pushed the fix-manifestEnhancer-invalid-locale branch 2 times, most recently from eb9d5d2 to 11ab19f Compare September 11, 2024 15:14
@matz3 matz3 requested review from a team and removed request for a team September 11, 2024 15:24
@matz3 matz3 force-pushed the fix-manifestEnhancer-invalid-locale branch from b2fe975 to 9aea297 Compare September 12, 2024 13:59
@matz3 matz3 force-pushed the fix-manifestEnhancer-invalid-locale branch from 2c592a4 to 2745dba Compare October 7, 2024 12:21
@flovogt flovogt removed the bug label Mar 7, 2025
@matz3 matz3 force-pushed the fix-manifestEnhancer-invalid-locale branch from b10b5d7 to c8d83f1 Compare May 8, 2025 13:43
@matz3 matz3 requested review from RandomByte and codeworrior May 8, 2025 13:44
Copy link
Member

@codeworrior codeworrior left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with the code change. I struggled a bit wit hthe commit message. Would you mind detailing what "This is due to the fact that the ResourceBundle does use the legacy Java locale format for the request URL." means?

I guess you refer to the fact that not very possible part of a BCP47 language tag will be used by ResourceBundle for the outgoing requests (e.g. the script is currently ignored except for sr_Latn).

The references in the runtime code are meanwhile outdated (code moved to LanguageFallback), but they use a commit ID, so they continue to work.

matz3 and others added 8 commits May 15, 2025 13:43
This fixes two problems that could have occurred:

A properties file with an invalid locale was still taken into the list
of supported locales, which then caused a runtime exception in the
ResourceBundle as it validates the input.

Another problem was that properties files could have a valid name
according to BCP47, but the file won't be ever requested with that name.
This is due to the fact that the ResourceBundle does not use the
extension / private use sections of the locale when creating the request
URL.

In both cases, the properties file is now ignored and no entry for the
supportedLocales is created.
sapprc is not a valid supportability locale
@matz3 matz3 force-pushed the fix-manifestEnhancer-invalid-locale branch from c8d83f1 to de919a1 Compare May 15, 2025 11:43
@matz3
Copy link
Member Author

matz3 commented May 16, 2025

I'm fine with the code change. I struggled a bit wit hthe commit message. Would you mind detailing what "This is due to the fact that the ResourceBundle does use the legacy Java locale format for the request URL." means?

I guess you refer to the fact that not very possible part of a BCP47 language tag will be used by ResourceBundle for the outgoing requests (e.g. the script is currently ignored except for sr_Latn).

The references in the runtime code are meanwhile outdated (code moved to LanguageFallback), but they use a commit ID, so they continue to work.

With that I meant that the runtime never requests BCP47 language tags (i.e. dash-separated). It always uses the Java locale format (separated by underscores), isn't it?

@codeworrior
Copy link
Member

I didn't doubt that the comment is in general right (it is). It just took me a while to get what exactly this means.

Adding some details or examples would have helped to understand the problem better. The difference between "_" and "-" is one such detail. The runtime also won't sent out certain subtags, e.g. the script (except for sr_Latn) and others (e.g. private extensions other than those for the pseudo languages).

Well, but I don't want to overcomplicate it.

@matz3
Copy link
Member Author

matz3 commented May 16, 2025

@codeworrior thanks for your feedback. I've updated the commit message and also updated the code references.

@matz3 matz3 requested a review from codeworrior May 16, 2025 11:05
Copy link
Member

@codeworrior codeworrior left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the updates! LGTM.

@matz3 matz3 merged commit a6c04d2 into main May 16, 2025
18 checks passed
@matz3 matz3 deleted the fix-manifestEnhancer-invalid-locale branch May 16, 2025 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants