Skip to content

Commit

Permalink
Add project key to cache key
Browse files Browse the repository at this point in the history
If a requests is sent with a project key, and the key is not part of the cache key, following requests for other projects will result in the cached repositories for the first project, leading to wrong results
  • Loading branch information
thomas-boehm-tractive committed Apr 2, 2024
1 parent abe474d commit c51763a
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -784,11 +784,17 @@ public List<BitbucketCloudRepository> getRepositories(@CheckForNull UserRoleInRe
.set("pagelen", MAX_PAGE_LENGTH);
if (StringUtils.isNotBlank(projectKey)) {
template.set("q", "project.key=" + "\"" + projectKey + "\""); // q=project.key="<projectKey>"
cacheKey.append("::").append(projectKey);
} else {
cacheKey.append("::<undefined>");
}
if (role != null && authenticator != null) {
template.set("role", role.getId());
cacheKey.append("::").append(role.getId());
} else {
cacheKey.append("::<undefined>");

Check warning on line 795 in src/main/java/com/cloudbees/jenkins/plugins/bitbucket/client/BitbucketCloudApiClient.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 787-795 are not covered by tests
}

Callable<List<BitbucketCloudRepository>> request = () -> {
List<BitbucketCloudRepository> repositories = new ArrayList<>();
Integer pageNumber = 1;
Expand Down

0 comments on commit c51763a

Please sign in to comment.