Repository navigation
Tidy up how API error messages are built - #25817
Merged
Merged
Conversation
chippison
force-pushed
the
api-error-message-rewrite-5x
branch
from
November 25, 2026 08:29
109628a to
9ee6253
Compare
chippison
enabled auto-merge (squash)
December 1, 2026 05:43
10 tasks
tzi
reviewed
Dec 1, 2026
Build the message for API and report responses in one helper, and keep mail server replies in the log for web requests.
…errors a fixed message Log records no longer look for the configured credentials, and the limit errors of the database account get a fixed message. Mail failures are logged as a warning.
Brings the backport in line with the latest changes of #25789, with the deprecation noted in the changelog.
chippison
force-pushed
the
api-error-message-rewrite-5x
branch
from
December 1, 2026 20:41
3b6e996 to
b5fc68b
Compare
Adds the tests of #25789 that could not be backported before the SMTP OAuth backend reached 5.x.
nathangavin
approved these changes
Dec 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DEV-21093
Error responses that print no backtrace (API responses and report loading errors) now build their message in one helper,
ExceptionHandler::getMessageForResponse(), instead of going through the log text processor. The safe mode output passes its backtrace throughredactForDebugOutput()like other backtraces do.Log records are rewritten the same way as these responses: the token, the salt, the root path and the database account in its
'user'@'host'form. They go throughredactForDisplay()and no longer have the configured credentials replaced, because log entries are shown in notifications and in the log viewer. The error output of development mode,PIWIK_PRINT_ERROR_BACKTRACEand the command line keeps the existing filtering. What is written to the log does not.The two methods are named after the output they are for:
ExceptionHandler::redactForDisplay()for text shown to users or written to the log, andExceptionHandler::redactForDebugOutput()for output that prints backtraces.replaceSensitiveValues()is the old name of the second one and stays as a deprecated alias until Matomo 7.When the database server reports that the database account reached one of its limits (MySQL errors 1203 and 1226), a fixed message is shown (
General_ExceptionDatabaseResourceLimit). This applies when connecting (the tracker's connection included), on the connection error page, in API and report error responses, and in the log.A failed email send in a web request now shows a short translated message (
General_ExceptionEmailNotSent) and writes the details to the log as a warning. Super users get a variant that says how to see the details (General_ExceptionEmailNotSentSuperUser), because with the default log configuration that warning is not written anywhere. On the command line the full error is shown as before, socore:test-emailstill gives the reason.Known limitations
The database account is recognised by the
'user'@'host'form the database server uses in its messages. These cases are accepted as they are:'a'@'b'form is rewritten too.PIWIK_PRINT_ERROR_BACKTRACE, command line archiving) rely on#[\SensitiveParameter]to hide argument values, which PHP 7.2 to 8.1 ignore. A failed database connection no longer carries the exception of the connect call, so its backtrace holds neither the user name nor the password on any PHP version. The tracker has its own connect call and drops that exception as well. PHPMailer does not mark the password argument of its SMTP authentication.Apart from the backtrace cases, the text that can still be shown comes from the database server: the account name, and for a failed connection the database host or the database name.
Review
Backport of #25789.