Skip to content

Answer a missing alert with 404 and another user's alert with 403 - #303

Merged
snake14 merged 3 commits into
6.x-devfrom
customalerts-http-exceptions
Nov 6, 2026
Merged

snake14 merged 3 commits into
6.x-devfrom
customalerts-http-exceptions

Conversation

@snake14

@snake14 snake14 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Description

CustomAlerts now answers a request for an alert that does not exist with HTTP 404, and a request for another user's alert with HTTP 403, instead of HTTP 200 with an error result. This covers getAlert, editAlert, deleteAlert and getValuesForAlertInPast. The alert edit page and the internal formatAlerts controller action, which answered a server error (HTTP 500), now answer with the same 404 or 403.

Deleting or saving an alert that was deleted in another tab still shows its message, in a toast, because Matomo's UI only shows a generic error for a 4xx response. Validation errors when saving an alert are unchanged.

Issue No

N/A, follow-up to core's switch to HTTP 4xx exceptions for client errors.

Steps to Replicate the Issue

  1. Call index.php?module=API&method=CustomAlerts.getAlert&idAlert=99999&format=json with a valid token_auth.
  2. Expected: "Alert with ID 99999 does not exist!" with HTTP 404.
  3. Actual: the same message with HTTP 200.

Checklist

  • [✔] Tested locally or on demo2/demo3?
  • [✔] New test case added/updated?
  • [NA] Are all newly added texts included via translation?
  • [NA] Are text sanitized properly? (Eg use of v-text v/s v-html for vue)
  • [✔] Version bumped?
  • [✔] I have understood, reviewed, and tested all AI outputs before use
  • [✔] All AI instructions respect security, IP, and privacy rules
  • [NA] Documentation updated?

…tead of 500

Delete and save show the message of a 4xx in a toast, since AjaxHelper only shows its generic error for one.
@snake14
snake14 requested a review from a team November 5, 2026 23:03
@snake14 snake14 changed the title Answer a missing alert with 404 and another user's alert with 403 instead of 500 Answer a missing alert with 404 and another user's alert with 403 Nov 5, 2026

@lachiebol lachiebol left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@snake14
snake14 merged commit fc3233d into 6.x-dev Nov 6, 2026
23 checks passed
@snake14
snake14 deleted the customalerts-http-exceptions branch November 6, 2026 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants