fix(rest): make visibility field case-insensitive in REST API#4150
Open
preet-p1981 wants to merge 1 commit into
Open
fix(rest): make visibility field case-insensitive in REST API#4150preet-p1981 wants to merge 1 commit into
preet-p1981 wants to merge 1 commit into
Conversation
The convertToProject() method in ProjectController used String.toUpperCase() without an explicit Locale, and lacked validation against the Visibility enum. This caused two problems:
* Locale-dependent uppercasing (Turkish 'i' bug).
* Confusing failures when a client sent a value like 'private' or 'Private'
instead of the canonical 'PRIVATE'.
Introduce a small static helper, ProjectController#parseVisibility(String),
that:
* trims whitespace,
* uppercases using Locale.US,
* validates against Visibility.values(),
* throws IllegalArgumentException with the list of valid values when the
input is unknown.
Add unit tests for the helper and two MockMvc regression tests that POST a
project with lowercase / mixed-case visibility values.
Fixes eclipse-sw360#2569
Signed-off-by: preet-p1981 <preetpatelpjp@gmail.com>
GMishx
requested changes
May 26, 2026
GMishx
left a comment
Member
There was a problem hiding this comment.
Minor changes needed.
Also @preet-p1981 , please sign the ECA. Without it, we cannot accept changes from you. You can see, the status is failed in the CI checks.
| return null; | ||
| } | ||
| try { | ||
| return Visibility.valueOf(value.trim().toUpperCase(Locale.US)); |
| * @return matching {@link Visibility} or {@code null} if input is null/blank | ||
| */ | ||
| static Visibility parseVisibility(String value) { | ||
| if (value == null || value.trim().isEmpty()) { |
Member
There was a problem hiding this comment.
Please use CommonUtils.isNullEmptyOrWhitespace()
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.
The convertToProject() method in ProjectController used String.toUpperCase() without an explicit Locale, and lacked validation against the Visibility enum. This caused two problems:
Introduce a small static helper, ProjectController#parseVisibility(String), that:
Add unit tests for the helper and two MockMvc regression tests that POST a project with lowercase / mixed-case visibility values.
Fixes #2569
Issue:
Suggest Reviewer
How To Test?
Checklist
Must: