SonarSource/sonarqube · error · IllegalArgumentException
Exactly one project needs to be provided in the 'components'
Error message
Exactly one project needs to be provided in the 'components' param when used together with 'fixedInPullRequest' param
What it means
IssueQueryFactory.getIssuesFixedByPullRequest requires that when the fixedInPullRequest parameter is used, the components param contains exactly one project key. Otherwise it throws IllegalArgumentException explaining that exactly one project must be provided with 'fixedInPullRequest'.
Source
Thrown at server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java:211
if (request.getFixedInPullRequest() != null) {
issueKeys = getIssuesFixedByPullRequest(dbSession, request);
}
List<String> requestIssues = request.getIssues();
if (requestIssues != null && !requestIssues.isEmpty()) {
if (issueKeys == null) {
issueKeys = new ArrayList<>();
}
issueKeys.addAll(requestIssues);
}
return issueKeys;
}
private Collection<String> getIssuesFixedByPullRequest(DbSession dbSession, SearchRequest request) {
String fixedInPullRequest = request.getFixedInPullRequest();
checkArgument(StringUtils.isNotBlank(fixedInPullRequest), "Parameter '%s' is empty", PARAM_FIXED_IN_PULL_REQUEST);
List<String> componentKeys = request.getComponentKeys();
if (componentKeys == null || componentKeys.size() != 1) {
throw new IllegalArgumentException("Exactly one project needs to be provided in the " +
"'" + PARAM_COMPONENTS + "' param when used together with '" + PARAM_FIXED_IN_PULL_REQUEST + "' param");
}
String projectKey = componentKeys.get(0);
ProjectDto projectDto = dbClient.projectDao().selectProjectByKey(dbSession, projectKey)
.orElseThrow(() -> new IllegalArgumentException("Project with key '" + projectKey + "' does not exist"));
BranchDto pullRequest = dbClient.branchDao().selectByPullRequestKey(dbSession, projectDto.getUuid(), fixedInPullRequest)
.orElseThrow(() -> new IllegalArgumentException("Pull request with key '" + fixedInPullRequest + "' does not exist for project " +
projectKey));
String branch = request.getBranch();
if (branch != null) {
BranchDto targetBranch = dbClient.branchDao().selectByBranchKey(dbSession, projectDto.getUuid(), branch)
.orElseThrow(() -> new IllegalArgumentException("Branch with key '" + branch + "' does not exist"));
if (!Objects.equals(targetBranch.getUuid(), pullRequest.getMergeBranchUuid())) {
throw new IllegalArgumentException("Pull request with key '" + fixedInPullRequest + "' does not target branch '" + branch + "'");
}
}
return dbClient.issueFixedDao().selectByPullRequest(dbSession, pullRequest.getUuid())View on GitHub (pinned to 184c821202)
Solutions
- Pass exactly one project key in the components param together with fixedInPullRequest.
- Remove fixedInPullRequest if you intend a multi-project search.
- Ensure the provided project key actually exists (the next check rejects unknown keys).
Example fix
// before
searchRequest.componentKeys(Arrays.asList("proj-a", "proj-b")).fixedInPullRequest("PR-12");
// after
searchRequest.componentKeys(Collections.singletonList("proj-a")).fixedInPullRequest("PR-12"); Defensive patterns
Strategy: validation
Validate before calling
if (fixedInPullRequest != null && (componentKeys == null || componentKeys.size() != 1)) {
throw new IllegalArgumentException("fixedInPullRequest requires exactly one component");
} Try / catch
try { search(req); } catch (IllegalArgumentException e) { if (e.getMessage().contains("fixedInPullRequest")) { /* adjust components param */ } } Prevention
- Only set fixedInPullRequest for single-project queries
- Validate request parameters before sending
- Keep PR search UIs scoped to one project
When it happens
Trigger: Calling api/issues/search (or the facet equivalent) with fixedInPullRequest set but componentKeys null, empty, or containing 2+ keys; collectIssueKeys routes pull-request searches here whenever fixedInPullRequest is present.
Common situations: Cross-project searches that accidentally include the fixedInPullRequest filter; UI clients passing the whole multi-selected component list along with the PR filter.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Bad sort field:
- Pull request with key '{}' does not target branch '{}'
- a JVM option can't be empty and must start with '-'. The fol
- Unknown severity: %s
- me.getMessage() (invalid offset date-time parameter passed t
AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09).
Data as JSON: /api/errors/aaf5f62e15da3e16.
Report an issue: GitHub.