RI-8267 Complete error-code coverage for i18n#6120
Conversation
🛡️ Jit Security Scan Results✅ No security findings were detected in this PR
Security scan by Jit
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6d4b15b79f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Code Coverage - Integration Tests
|
6d4b15b to
30f1209
Compare
30f1209 to
b9ec404
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b9ec404ce7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
b9ec404 to
8ac1d48
Compare
Assign CustomErrorCodes to the SSH connection/tunnel exceptions so clients can translate them. Additive — message/name/statusCode unchanged. Ref: RI-8267 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Assign CustomErrorCodes to the encryption/keytar exceptions (incl. the base) so clients can translate them. Additive only. Ref: RI-8267 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Assign CustomErrorCodes to the database-import validation exceptions (invalid certs/keys/compressor, file parsing, etc.). Additive only. Ref: RI-8267 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add CustomErrorCodes.RdiTimeout and assign codes to the RDI internal-server and timeout exceptions; update their specs. Additive only. Ref: RI-8267 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Assign CustomErrorCodes to the remaining codeless exceptions: feature remote-config fetch and redis client-not-found. Additive only. Ref: RI-8267 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…(RI-8267) GlobalExceptionFilter stamps an errorCode onto any HttpException lacking one: ValidationError for class-validator (array message) failures, else a status-based Generic* code. Covers built-in Nest exceptions across the app without touching throw sites. Custom-coded exceptions are left untouched; response shape is otherwise unchanged. Ref: RI-8267 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add an "Error Codes" Bruno folder demonstrating errorCode/resource in responses: connection failed (custom code), not found (generic code), validation error, and already-exists (resource). Ref: RI-8267 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
8ac1d48 to
8a78ebd
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8a78ebd7dd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…RI-8267) The body-parser error middleware writes the 413 entity.too.large response directly, bypassing GlobalExceptionFilter. Extract the stamping into a shared stampErrorCode helper and use it there too, so the payload-too-large error carries an errorCode like every other user-facing API error. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
What
Give every user-facing API error a stable
errorCode(and structuredresourcedata where it already exists) so the client can translate error messages on its own. The backend localizes nothing — it just exposes a code clients can map to a translated string.Strictly additive & backwards-compatible:
message(English),statusCode, anderror/nameare untouched.Note: This API is also consumed by the Redis-for-VS-Code plugin, so not changing the response shape is a hard requirement.
Why
Pre-PR, ~58/78 custom exceptions carried an
errorCode, but nothing was translatable for:NotFoundException,BadRequestException, …),This PR closes those gaps so the upcoming UI work can map any error to a localized message, with the English
messagealways available as a fallback. Nonestjs-i18n/Accept-Language— translation stays client-side.Commit breakdown (by change type)
1. Specific codes for codeless custom exceptions — add an
errorCodefromCustomErrorCodesto each, one line per file, response shape otherwise unchanged. Grouped per domain:feat(api): error codes for SSH exceptionsfeat(api): error codes for encryption exceptionsfeat(api): error codes for database-import exceptionsfeat(api): error codes for RDI exceptions(+ addsRdiTimeout, updates 2 specs)feat(api): error codes for misc exceptions(feature remote-config, redis client-not-found)2. Generic chokepoint —
feat(api): inject generic + validation error codes via global filter.GlobalExceptionFilterstamps a code onto anyHttpExceptionstill missing one:ValidationErrorwhenmessageis an array (class-validator), otherwise a status-basedGeneric*code. Covers all built-in Nest throws + validation in one place, without editing ~149 throw sites. Custom-coded exceptions are left untouched.3. Docs —
docs(api): bruno error-code examples. A Bruno "Error Codes" folder with runnable requests showing each case.New code-ranges in
custom-error-codes.ts:116xx117xx118xx119xx124xx/125xx(12_000 + HTTP status)12100Response shapes (with these changes)
Custom exception (now coded) — SSH:
{ "message": "Unable to create ssh connection. ...", "name": "UnableToCreateSshConnectionException", "statusCode": 503, "errorCode": 11600 }Generic built-in exception — 404 on an unknown id:
{ "message": "Invalid database instance id.", "statusCode": 404, "error": "Not Found", "errorCode": 12404 }Validation failure (note
messagestays an array of field errors):{ "message": ["port must be a number conforming to the specified constraints"], "statusCode": 400, "error": "Bad Request", "errorCode": 12100 }Exception carrying structured context —
DatabaseAlreadyExists:{ "message": "The database already exists.", "statusCode": 409, "error": "DatabaseAlreadyExists", "errorCode": 11200, "resource": { "databaseId": "a1b2c3d4-..." } }How we'll use this (next PR, UI — pseudo-code)
A small
errorCode → i18n keymap plus a translate helper.resourcesupplies interpolation vars.Note: the English
messageis the fallback when a code isn't mapped yet.So this PR is the data contract; the next PR adds the map + locale strings and wires
translateApiErrorinto the UI's error surfaces.Testing
yarn lint:api,yarn --cwd redisinsight/api type-check(baseline) — clean.yarn test:api— green; updated the 3 specs that asserted fullgetResponse()shapes, added aGlobalExceptionFilterspec (status→code mapping, validation array →ValidationError, doesn't overwrite existing codes, non-HttpException passthrough, static-asset branch).POST /databases/test,GET /databases/:id) reproduces each case live againstyarn dev:api.Ref: RI-8267
Related community requests: #605, #1317, #1883, #2040, #2137, #2181, #2213, #2417, #2550, #2590, #2695, #2715, #2716, #2727, #2828, #2912, #2943, #2945, #3081, #3141, #3142, #3319, #3411, #3601, #3625, #3628, #3663, #3671, #3812, #3815, #4150, #4182, #4408, #4664, #4672, #4744, #5052, #5967
Note
Medium Risk
Broad change to global error serialization affects every API error path (including encryption/SSH), but behavior is additive and existing fields are preserved; regression risk is mainly wrong or missing codes on edge cases.
Overview
Adds an optional
errorCode(and keeps existingresourcewhere present) on API error responses so clients can translate errors without backend localization.message,statusCode, anderrorare unchanged.Central stamping: New
stampErrorCoderuns inGlobalExceptionFilterfor everyHttpExceptionmissing a code—12100whenmessageis a class-validator array, otherwise12_000 + HTTP status(e.g. 404 →12404). Existing custom codes are not overwritten. The body-parser 413 path uses the same helper.Domain exceptions: SSH, encryption, database-import, RDI (incl.
RdiTimeout), remote-config, and redis client-not-found responses now set explicitCustomErrorCodes.ValidationExceptionembedsValidationErrorin its body.Docs/tests: Bruno Error Codes requests document live shapes; new/updated specs cover the filter, body-parser, and RDI timeout/internal-error responses.
Reviewed by Cursor Bugbot for commit b04f7b1. Bugbot is set up for automated code reviews on this repo. Configure here.