Skip to content
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

Fix where memeber or token with null permission #1076

Merged
merged 2 commits into from
Dec 24, 2024

Conversation

minwoox
Copy link
Member

@minwoox minwoox commented Dec 24, 2024

I discovered a case that a member with null permission is added to the metadata.

@minwoox minwoox added the defect label Dec 24, 2024
@minwoox minwoox added this to the 0.73.1 milestone Dec 24, 2024
for (Entry<String, Collection<Permission>> entry : permissions.entrySet()) {
final Collection<Permission> value = entry.getValue();
if (!value.isEmpty()) {
final RepositoryRole repositoryRole = repositoryRole(value);
Copy link
Contributor

Choose a reason for hiding this comment

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

repositoryRole already returns null if value is empty. How about setting repositoryRole if it is not null to avoid double-checking.

final RepositoryRole repositoryRole = repositoryRole(value);
if (!repositoryRole) {
    builder.put(entry.getKey(), repositoryRole);
}

Otherwise, add a filter condition to the existing stream operations?

permissions.entrySet().stream()
           .filter(sce -> !sce.getValue().isEmpty())
           .collect(toImmutableMap(Entry::getKey, entry -> repositoryRole(entry.getValue())));

Copy link
Member Author

Choose a reason for hiding this comment

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

Good suggestion. Applied. 👍

@minwoox minwoox merged commit c3f635a into line:main Dec 24, 2024
9 of 10 checks passed
@minwoox minwoox deleted the fix_null_member branch December 24, 2024 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants