SonarSource/sonarqube · error · IllegalArgumentException
Param projectKeys is invalid.
Error message
Param projectKeys is invalid.
What it means
SonarLintPushAction.validateParams loads projects for the given projectKeys and throws IllegalArgumentException 'Param projectKeys is invalid.' when fewer projects are found than keys were provided, or none at all — meaning at least one provided key does not match an existing project.
Source
Thrown at server/sonar-webserver-pushapi/src/main/java/org/sonar/server/pushapi/sonarlint/SonarLintPushAction.java:140
Set<String> getLanguages() {
return languages;
}
private Set<String> parseParam(String paramKey) {
String paramProjectKeys = request.getParam(paramKey).getValue();
if (paramProjectKeys == null) {
throw new IllegalArgumentException("Param " + paramKey + " was not provided.");
}
return Set.of(paramProjectKeys.trim().split(","));
}
private void validateParams() {
List<ProjectDto> projectDtos;
try (DbSession dbSession = dbClient.openSession(false)) {
projectDtos = dbClient.projectDao().selectProjectsByKeys(dbSession, projectKeys);
}
if (projectDtos.size() < projectKeys.size() || projectDtos.isEmpty()) {
throw new IllegalArgumentException("Param " + PROJECT_PARAM_KEY + " is invalid.");
}
}
}
}
View on GitHub (pinned to 184c821202)
Solutions
- Validate each key via api/projects/search before calling and send only keys of existing projects.
- Remove keys of deleted/renamed projects from the client configuration.
- Ensure you use top-level project keys, not module or branch keys.
Example fix
// before
Set<String> keys = Set.of("old-project", "my-project"); // old-project deleted
// after
Set<String> keys = Set.of("my-project"); // only existing projects Defensive patterns
Strategy: validation
Validate before calling
Set<String> existing = dbClient.projectDao().selectProjectsByKeys(dbSession, projectKeys)
.stream().map(ProjectDto::getKey).collect(toSet());
if (!existing.containsAll(projectKeys)) { /* drop or fix unknown keys before the call */ } Try / catch
try { pushAction.validateParams(); } catch (IllegalArgumentException e) { if (e.getMessage().contains("is invalid")) { /* re-sync project keys */ } } Prevention
- Keep client-side project-key lists in sync with the server
- Filter keys through api/projects/search before sending
- Use project keys, not module or branch keys
When it happens
Trigger: Passing projectKeys containing a nonexistent or deleted project key, or a branch/component key instead of a project key, so selectProjectsByKeys returns fewer rows than requested keys.
Common situations: Projects deleted or renamed in SonarQube while clients still reference old keys; typos in project keys; using module keys rather than project keys in the parameter.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- User does not exist
- User doesn't have rights to requested resource anymore.
- Param {paramKey} was not provided.
- a JVM option can't be empty and must start with '-'. The fol
- Unknown severity: %s
AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09).
Data as JSON: /api/errors/de75f93efb09bb25.
Report an issue: GitHub.