SonarSource/sonarqube · error · IllegalArgumentException
An ' ' event with the same name already exists on analysis
Error message
An '%s' event with the same name already exists on analysis '%s'
What it means
Thrown from CreateEventAction.throwException when creating an event of category OTHER (e.g. 'Quality Gate' status change) on an analysis that already has an event of that category with the exact same name. SonarQube forbids two same-named OTHER events on one analysis. The '%s' placeholder is filled with the category label.
Solutions
- List existing events on the analysis and skip creation when an event with the same name/category already exists.
- Delete the existing event (POST api/projects/delete_event) if the new event should replace it.
- Rename the new event so it is unique on that analysis.
- Make retries idempotent by correlating client-generated event names.
Example fix
// before
createEvent(analysisUuid, "OTHER", "Quality gate changed"); // 400 if duplicate
// after
boolean exists = getEvents(analysisUuid).stream()
.anyMatch(e -> "OTHER".equals(e.getCategory()) && "Quality gate changed".equals(e.getName()));
if (!exists) {
createEvent(analysisUuid, "OTHER", "Quality gate changed");
} Defensive patterns
Strategy: validation
Validate before calling
boolean dup = getEvents(analysisUuid).stream()
.anyMatch(e -> name.equals(e.getName()) && !"VERSION".equals(e.getCategory()));
if (dup) { /* skip, rename, or delete existing */ } Try / catch
try {
createEvent(analysisUuid, "OTHER", name);
} catch (SonarQubeClientException e) {
if (e.getMessage() != null && e.getMessage().contains("event with the same name already exists")) {
LOG.info("duplicate OTHER event ignored");
} else throw e;
} Prevention
- Generate unique event names (include timestamp) in automation
- Do not blind-retry create_event calls after timeouts without dedup checks
- Fetch existing events before bulk imports
When it happens
Trigger: POST api/projects/create_event with category=OTHER (or QUALITY_GATE) and a name identical to an existing event on the same analysis uuid. Retrying a failed event-creation call. Automated importers writing alert/status events repeatedly.
Common situations: Scripts re-importing history that re-create events like 'Quality gate changed'; retry logic that replays a create_event request after a timeout although the first request succeeded.
Understand the failure class
Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.
Related errors
- A version event already exists on analysis
- An ' ' event with the same name already exists on analysis
- An DevOps Platform setting with key
- Analysis ' ' not found
- Backup XML is not valid. Root element must be
AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09).
Data as JSON: /api/errors/f3e8fc47d08adfc2.
Report an issue: GitHub.
Appendix: source
Thrown at server/sonar-webserver-webapi/src/main/java/org/sonar/server/projectanalysis/ws/CreateEventAction.java:206
switch (request.getCategory()) {
case VERSION:
return dbEvent -> VERSION.getLabel().equals(dbEvent.getCategory());
case OTHER:
return dbEvent -> OTHER.getLabel().equals(dbEvent.getCategory()) && request.getName().equals(dbEvent.getName());
default:
throw new IllegalStateException("Event category not handled: " + request.getCategory());
}
}
private static Consumer<EventDto> throwException(CreateEventRequest request) {
switch (request.getCategory()) {
case VERSION:
return dbEvent -> {
throw new IllegalArgumentException(format("A version event already exists on analysis '%s'", request.getAnalysis()));
};
case OTHER:
return dbEvent -> {
throw new IllegalArgumentException(format("An '%s' event with the same name already exists on analysis '%s'", OTHER.getLabel(), request.getAnalysis()));
};
default:
throw new IllegalStateException("Event category not handled: " + request.getCategory());
}
}
private static class CreateEventRequest {
private final String analysis;
private final EventCategory category;
private final String name;
private CreateEventRequest(Builder builder) {
analysis = builder.analysis;
category = builder.category;
name = builder.name;
}
public String getAnalysis() {View on GitHub (pinned to 184c821202)