fix(ui): improve i18n toast and duplicate slug error handling #7254
fix(ui): improve i18n toast and duplicate slug error handling #7254anonatul wants to merge 3 commits intolouislam:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves user-facing messaging in the Vue frontend by ensuring a “test notification requested” success toast is translatable via i18n and by broadening duplicate-slug detection for status page creation errors across common database backends.
Changes:
- Replaced a hardcoded “test notification requested” toast in
Details.vuewith an i18n key. - Added the new
testNotificationRequestedentry toen.json. - Expanded duplicate-slug error matching in
AddStatusPage.vueto handle common “unique/duplicate/already exists” DB message variants.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/pages/Details.vue | Switches toast to use an i18n key for the “test notification requested” message. |
| src/pages/AddStatusPage.vue | Improves duplicate slug detection by matching additional common DB error message patterns. |
| src/lang/en.json | Adds the testNotificationRequested translation string. |
| const msg = res.msg.toLowerCase(); | ||
| if ( | ||
| msg.includes("unique constraint") || | ||
| msg.includes("duplicate entry") || | ||
| msg.includes("already exists") | ||
| ) { |
There was a problem hiding this comment.
how did you come up with these 3 strigns, where are they coming from?
This beind different computes for me, but I don't understand why 3.. we only have 2 possible DB backends
There was a problem hiding this comment.
yes actually those 3 strings are not 3 DB backends they’re 3 possible error message fragments that can be returned in res.msg for a unique or duplicate violation
There was a problem hiding this comment.
Which error messages would this be and how can I reproduce them?
To explain why I am asking this:
The reproducing is important to me to ensure that we don't accidentally merge code which was hallucinated. I am saying that this is, we just have to be a bit more carfull as a large-ish OSS project. -> https://github.com/louislam/uptime-kuma/pulls?q=is%3Apr+label%3Aai-slop+is%3Aclosed
There was a problem hiding this comment.
i get it.. here unique constraint covers SQLite's default error message. duplicate entry handles MariaDB/MySQL, which throws ER_DUP_ENTRY. already exists is a catch-all for anything generic coming out of the ORM.
To reproduce it: i spin up Kuma with MariaDB instead of the default SQLite, create a status Page with a slug like test-slug, then try to create another one with the same slug. without this fix, MariaDB users just get a raw database error instead of the friendly validation message, because the old code only checked for SQLite's exact error string
There was a problem hiding this comment.
So if the sqlite error is when running sqlite and the mariadb error is for mariadb, how is the third error created?
There was a problem hiding this comment.
the third one isn't tied to any specific DB engine.. "already exists" is there because res.msg doesn't always contain the raw driver error
if you'd rather only match known raw DB strings, happy to drop it and keep just the sqllite and mariadb patterns
i added it mainly to avoid regressions when the backend abstracts the message
There was a problem hiding this comment.
under which case can you trigger this? Why exactly did you add this?
I am fine with it if there is a reason
There was a problem hiding this comment.
i added it defensively because res.msg isn't a stable API. depending on the DB, driver, or how the ORM wraps things,
the UI could end up receiving a normalized message like "status page already exists" or "record already exists" instead of the raw sqlite or mariadb text and in that case we'd still want to show the friendly toast rather than nothing
There was a problem hiding this comment.
please only add things that you:
- have tested
- actually fix a problem, add a feature or make the code better
Random "savety" checks don't do that
Summary
In this pull request, the following changes are made:
Replaced a hardcoded success toast in
src/pages/Details.vuewith i18n keytestNotificationRequested.Added
testNotificationRequestedtosrc/lang/en.jsonso it is translatable.Improved duplicate slug error handling in
src/pages/AddStatusPage.vueby checking common DB error messages (unique constraint,duplicate entry,already exists) and showing a friendly localized message.Relates to #issue-number
Resolves #issue-number
Please follow this checklist to avoid unnecessary back and forth (click to expand)
I understand that I am responsible for and able to explain every line of code I submit.
AI/LLM Usage Disclosure
Screenshots for Visual Changes
No visual layout change (toast text/error handling only), so screenshots are not applicable.