fix(errors): show a route's Swedish message even without a keyword match (#2086) (#2253)

* fix(errors): show a route's Swedish message even without a keyword match (#2086)

getErrorMessage passed a route's free-text `error` / `message` through
only if it contained one of ~30 keywords ("kunde inte", "saknas", ...).
"Inget skattekonto är registrerat hos Skatteverket." has none, so the
skattekonto sync replaced the one sentence that would have helped with
"Ett oväntat serverfel uppstod. Försök igen senare.", which is wrong
advice for a company without a skattekonto. 155 of the 631 message_sv
strings in structured-errors.ts failed the same keyword test.

A second way in: looksLikeUserFacingSwedish accepts a string that reads
as Swedish (å/ä/ö, a strong Swedish word, or two weak function words)
and shows no sign of a technical leak (stack frames, file:line, JS/Node
error vocabulary, Postgres/PostgREST/SQL fragments, JSON, URLs). The
keyword list stays as the first way in. English framework text still
falls through to the status/context fallback, and a registry-wide test
pins that every message_sv now passes.

Closes #2086

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VnConrmMCxJRQ5kfiPPWyy

* test(errors): pin the two call sites whose Swedish messages now pass through (#2086)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VnConrmMCxJRQ5kfiPPWyy

---------

Co-authored-by: Jakob Wennberg <311770904+jakobwennberg-oss@users.noreply.github.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Jakob Wennberg
2026-09-03 18:55:33 +02:00
committed by GitHub
co-authored by Claude Fable 5.1 Jakob Wennberg
parent 5070041028
commit c3b7e79af8
4 changed files with 180 additions and 11 deletions
+4 -4
View File
@@ -69,10 +69,10 @@ describe('postAction', () => {
ok: false,
reason: 'server',
status: 404,
// The plain-string envelope this route emits is not recognized as a
// finished user sentence, so the status map answers: same text the old
// inline getErrorMessage(result, { statusCode }) produced.
message: 'Resursen kunde inte hittas.',
// The route's own Swedish sentence is shown as-is (issue #2086): it
// used to be dropped for lacking one of getErrorMessage's keywords and
// replaced by the status map's "Resursen kunde inte hittas.".
message: 'Ingen AGI för perioden 2026-04.',
})
})