{"record":{"id":"5cb85cc6a61019c8","repo":"SonarSource/sonarqube","slug":"message-s-cannot-be-dismissed","errorCode":null,"errorMessage":"Message '%s' cannot be dismissed.","messagePattern":"Message '(.+?)' cannot be dismissed\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":400,"severity":"warning","filePath":"server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/ws/DismissAnalysisWarningAction.java","lineNumber":90,"sourceCode":"      .setRequired(true)\n      .setExampleValue(Uuids.UUID_EXAMPLE_02);\n  }\n\n  @Override\n  public void handle(Request request, Response response) throws Exception {\n    userSession.checkLoggedIn();\n    String projectKey = request.mandatoryParam(PARAM_COMPONENT_KEY);\n    String messageKey = request.mandatoryParam(PARAM_MESSAGE_KEY);\n\n    try (DbSession dbSession = dbClient.openSession(false)) {\n      ProjectDto project = componentFinder.getProjectByKey(dbSession, projectKey);\n      userSession.checkEntityPermission(ProjectPermission.USER, project);\n\n      CeTaskMessageDto messageDto = dbClient.ceTaskMessageDao()\n        .selectByUuid(dbSession, messageKey)\n        .orElseThrow(() -> new NotFoundException(format(MESSAGE_NOT_FOUND, messageKey)));\n      if (!messageDto.getType().isDismissible()) {\n        throw new IllegalArgumentException(format(MESSAGE_CANNOT_BE_DISMISSED, messageKey));\n      }\n\n      Optional<UserDismissedMessageDto> result = dbClient.userDismissedMessagesDao().selectByUserAndProjectAndMessageType(dbSession,\n        userSession.getUuid(), project, messageDto.getType());\n      if (!result.isPresent()) {\n        dbClient.userDismissedMessagesDao().insert(dbSession, new UserDismissedMessageDto()\n          .setUuid(Uuids.create())\n          .setUserUuid(userSession.getUuid())\n          .setProjectUuid(project.getUuid())\n          .setMessageType(messageDto.getType()));\n        dbSession.commit();\n      }\n\n      response.noContent();\n    }\n  }\n\n}","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/ws/DismissAnalysisWarningAction.java#L72-L108","documentation":"DismissAnalysisWarningAction.handle dismisses a CE task message for the current user and project. The message must exist and its type must be dismissible; attempting to dismiss a non-dismissible type throws IllegalArgumentException with MESSAGE_CANNOT_BE_DISMISSED. It protects system-level messages (e.g. errors) that users cannot opt out of.","triggerScenarios":"POST api/analysis_warnings/dismiss (or equivalent CE message dismiss WS) with a message uuid whose CeTaskMessageType.isDismissible() is false, e.g. task failure/error messages.","commonSituations":"UI or automation trying to silence analysis-error or other system messages instead of genuine warnings; stale message keys from older tasks being re-dismissed.","solutions":["Only dismiss messages of dismissible types (analysis warnings); fix the underlying issue for error-type messages instead","Check the message type before calling the WS and skip non-dismissible ones","Locate the root cause of the message (e.g. failed quality gate task) rather than dismissing","Use a recent message uuid from the current task, not an archived one"],"exampleFix":"// before\ndismiss(messageKey) // type = TASK_FAILED (not dismissible)\n// after\nif (messageType.isDismissible()) { dismiss(messageKey); } else { resolveUnderlyingIssue(); }","handlingStrategy":"validation","validationCode":"Ce.TaskMessage msg = getMessage(key);\nif (msg == null || !msg.getType().isDismissible()) return; // skip before calling dismiss WS","typeGuard":"function isDismissible(msg) { return msg && DISMISSIBLE_TYPES.includes(msg.type); }","tryCatchPattern":"try { dismiss(key); } catch (BadRequest e) { log(\"message not dismissible; fix root cause\"); }","preventionTips":["Check message type in the task detail before dismissing","Only surface dismiss buttons for warning-type messages","Resolve error-type messages at the source (fix the analysis/quality gate issue)"],"tags":["java","sonarqube","web-api","validation"],"backgroundTag":"unsupported-operation","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}