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

UpdateEventAction.checkNonConflictingOtherEvents rejects an event update if any OTHER event on the same analysis — other than the one being updated — already has the same name. This enforces name uniqueness of OTHER events per analysis and is raised as IllegalArgumentException (HTTP 400).

Solutions

  1. Fetch events on the analysis (GET api/events?analysis=<uuid>) and pick a unique name before updating.
  2. Delete the conflicting sibling event if it is redundant.
  3. Append a distinguishing suffix (timestamp/sequence) to the event name.
  4. Handle 400 in scripts by regenerating a unique name and retrying once.

Example fix

// before
updateEvent(eventUuid, "Quality gate changed"); // 400 on name clash
// after
String name = "Quality gate changed";
boolean clash = getEvents(analysisUuid).stream()
  .anyMatch(e -> !eventUuid.equals(e.getUuid()) && name.equals(e.getName()));
if (clash) {
  name = name + " (" + Instant.now() + ")";
}
updateEvent(eventUuid, name);
Defensive patterns

Strategy: validation

Validate before calling

String newName = candidateName;
Set<String> taken = getEvents(analysisUuid).stream()
  .filter(e -> !eventUuid.equals(e.getUuid()))
  .map(Event::getName)
  .collect(Collectors.toSet());
while (taken.contains(newName)) { newName = candidateName + "-" + System.currentTimeMillis(); }

Try / catch

try {
  updateEvent(eventUuid, newName);
} catch (SonarQubeClientException e) {
  if (e.getMessage() != null && e.getMessage().contains("with the same name already exists")) {
    updateEvent(eventUuid, newName + "-" + System.currentTimeMillis());
  } else throw e;
}

Prevention

When it happens

Trigger: POST api/projects/update_event renaming (or keeping) an event's name to one that collides with a sibling event on the same analysis uuid. Merging event histories where two events share a name.

Common situations: Bulk scripts that normalize event names; importing events where two status-change entries were recorded with identical names; UI/API race where another user created the same-named event first.

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


AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09). Data as JSON: /api/errors/be0416f0ac8257cd. Report an issue: GitHub.

Appendix: source

Thrown at server/sonar-webserver-webapi/src/main/java/org/sonar/server/projectanalysis/ws/UpdateEventAction.java:145

  private EventDto getDbEvent(DbSession dbSession, UpdateEventRequest request) {
    checkArgument(isNotBlank(request.getName()), "A non empty name is required");
    return dbClient.eventDao().selectByUuid(dbSession, request.getEvent())
      .orElseThrow(() -> new NotFoundException(format("Event '%s' not found", request.getEvent())));
  }

  private Consumer<EventDto> checkPermissions() {
    return event -> userSession.checkComponentUuidPermission(ProjectPermission.ADMIN, event.getComponentUuid());
  }

  private Consumer<EventDto> checkNonConflictingOtherEvents(DbSession dbSession) {
    return candidateEvent -> {
      List<EventDto> dbEvents = dbClient.eventDao().selectByAnalysisUuid(dbSession, candidateEvent.getAnalysisUuid());
      Predicate<EventDto> otherEventWithSameName = otherEvent -> !candidateEvent.getUuid().equals(otherEvent.getUuid()) && otherEvent.getName().equals(candidateEvent.getName());
      dbEvents.stream()
        .filter(otherEventWithSameName)
        .findAny()
        .ifPresent(event -> {
          throw new IllegalArgumentException(format("An '%s' event with the same name already exists on analysis '%s'",
            candidateEvent.getCategory(),
            candidateEvent.getAnalysisUuid()));
        });
    };
  }

  private static Consumer<EventDto> checkVersionNameLength(UpdateEventRequest request) {
    return candidateEvent -> checkVersionName(candidateEvent.getCategory(), request.getName());
  }

  private SnapshotDto getAnalysis(DbSession dbSession, EventDto event) {
    return dbClient.snapshotDao().selectByUuid(dbSession, event.getAnalysisUuid())
      .orElseThrow(() -> new IllegalStateException(format("Analysis '%s' is not found", event.getAnalysisUuid())));
  }

  private static Function<EventDto, EventDto> updateNameAndDescription(UpdateEventRequest request) {
    return event -> {
      ofNullable(request.getName()).ifPresent(event::setName);

View on GitHub (pinned to 184c821202)