{"record":{"id":"aaf5f62e15da3e16","repo":"SonarSource/sonarqube","slug":"exactly-one-project-needs-to-be-provided-in-the-c","errorCode":null,"errorMessage":"Exactly one project needs to be provided in the 'components' param when used together with 'fixedInPullRequest' param","messagePattern":"Exactly one project needs to be provided in the 'components' param when used together with 'fixedInPullRequest' param","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":400,"severity":"error","filePath":"server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java","lineNumber":211,"sourceCode":"    if (request.getFixedInPullRequest() != null) {\n      issueKeys = getIssuesFixedByPullRequest(dbSession, request);\n    }\n    List<String> requestIssues = request.getIssues();\n    if (requestIssues != null && !requestIssues.isEmpty()) {\n      if (issueKeys == null) {\n        issueKeys = new ArrayList<>();\n      }\n      issueKeys.addAll(requestIssues);\n    }\n    return issueKeys;\n  }\n\n  private Collection<String> getIssuesFixedByPullRequest(DbSession dbSession, SearchRequest request) {\n    String fixedInPullRequest = request.getFixedInPullRequest();\n    checkArgument(StringUtils.isNotBlank(fixedInPullRequest), \"Parameter '%s' is empty\", PARAM_FIXED_IN_PULL_REQUEST);\n    List<String> componentKeys = request.getComponentKeys();\n    if (componentKeys == null || componentKeys.size() != 1) {\n      throw new IllegalArgumentException(\"Exactly one project needs to be provided in the \" +\n        \"'\" + PARAM_COMPONENTS + \"' param when used together with '\" + PARAM_FIXED_IN_PULL_REQUEST + \"' param\");\n    }\n    String projectKey = componentKeys.get(0);\n    ProjectDto projectDto = dbClient.projectDao().selectProjectByKey(dbSession, projectKey)\n      .orElseThrow(() -> new IllegalArgumentException(\"Project with key '\" + projectKey + \"' does not exist\"));\n    BranchDto pullRequest = dbClient.branchDao().selectByPullRequestKey(dbSession, projectDto.getUuid(), fixedInPullRequest)\n      .orElseThrow(() -> new IllegalArgumentException(\"Pull request with key '\" + fixedInPullRequest + \"' does not exist for project \" +\n        projectKey));\n\n    String branch = request.getBranch();\n    if (branch != null) {\n      BranchDto targetBranch = dbClient.branchDao().selectByBranchKey(dbSession, projectDto.getUuid(), branch)\n        .orElseThrow(() -> new IllegalArgumentException(\"Branch with key '\" + branch + \"' does not exist\"));\n      if (!Objects.equals(targetBranch.getUuid(), pullRequest.getMergeBranchUuid())) {\n        throw new IllegalArgumentException(\"Pull request with key '\" + fixedInPullRequest + \"' does not target branch '\" + branch + \"'\");\n      }\n    }\n    return dbClient.issueFixedDao().selectByPullRequest(dbSession, pullRequest.getUuid())","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java#L193-L229","documentation":"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'.","triggerScenarios":"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.","commonSituations":"Cross-project searches that accidentally include the fixedInPullRequest filter; UI clients passing the whole multi-selected component list along with the PR filter.","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)."],"exampleFix":"// before\nsearchRequest.componentKeys(Arrays.asList(\"proj-a\", \"proj-b\")).fixedInPullRequest(\"PR-12\");\n// after\nsearchRequest.componentKeys(Collections.singletonList(\"proj-a\")).fixedInPullRequest(\"PR-12\");","handlingStrategy":"validation","validationCode":"if (fixedInPullRequest != null && (componentKeys == null || componentKeys.size() != 1)) {\n  throw new IllegalArgumentException(\"fixedInPullRequest requires exactly one component\");\n}","typeGuard":null,"tryCatchPattern":"try { search(req); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"fixedInPullRequest\")) { /* adjust components param */ } }","preventionTips":["Only set fixedInPullRequest for single-project queries","Validate request parameters before sending","Keep PR search UIs scoped to one project"],"tags":["issues-search","pull-request","validation","java"],"backgroundTag":"missing-required-argument","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}