fix: send specific messageKey for FailedPrecondition errors to frontend - #2780
Open
t-kikuc wants to merge 3 commits into
Open
fix: send specific messageKey for FailedPrecondition errors to frontend#2780t-kikuc wants to merge 3 commits into
t-kikuc wants to merge 3 commits into
Conversation
All FailedPrecondition errors were sending the same generic messageKey
("FailedPreconditionError"), causing the frontend to display the same
generic message for every precondition failure. This adds a messageKey
override mechanism to BktError so each error can specify its own
translation key, matching the existing frontend i18n entries.
Refs #1253
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds per-error i18n message-key overrides so the frontend can display specific FailedPrecondition messages.
Changes:
- Adds chainable
BktError.WithMessageKey()with default fallback behavior. - Assigns specific keys to 19 API errors.
- Adds frontend translations and tests gRPC metadata propagation.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
pkg/error/error.go |
Implements message-key overrides. |
pkg/error/error_test.go |
Tests override and fallback behavior. |
pkg/api/api/grpc_status_test.go |
Tests overridden gRPC metadata. |
pkg/feature/api/error.go |
Assigns feature-specific keys. |
pkg/environment/api/error.go |
Assigns environment-specific keys. |
pkg/autoops/api/error.go |
Assigns AutoOps-specific keys. |
pkg/notification/api/error.go |
Assigns notification-specific key. |
pkg/tag/api/error.go |
Assigns tag-specific key. |
ui/dashboard/src/@locales/en/backend.json |
Adds English translations. |
ui/dashboard/src/@locales/ja/backend.json |
Adds Japanese translations. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…ite -> prerequisite) Address review comments on PR #2780: - Fix "suceeded" typo in error message, variable name, test, and log message - Fix "prerequsite" typo in error message and E2E test assertion Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…Features) Keep typo fix and WithMessageKey for statusInvalidArchive while honoring main's removal of statusVariationInUseByOtherFeatures. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
t-kikuc
marked this pull request as ready for review
August 28, 2026 08:50
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.
Refs #1253
What this PR does
Adds a
messageKeyOverridemechanism toBktErrorso thatFailedPrecondition(and other generic-type) errors can send a specific i18n key to the frontend instead of the generic error type string.Background
After the i18n migration (#1253),
BktError.MessageKey()always returnedstring(errorType)(e.g.,"FailedPreconditionError"). This worked forInvalidArgumenterrors because thefieldmetadata differentiates them, but allFailedPreconditionerrors shared the same messageKey and displayed the same generic message.The frontend already had specific translation keys (e.g.,
"CommentRequiredForUpdating","SegmentInUse","InvalidArchive"), but the backend never sent them. This PR connects the two.Before / After examples
All
FailedPreconditionerrors showed the same generic message:Points
WithMessageKey()is a chainable method on*BktError— no new constructor functions neededFailedPreconditionerrors across 5 packages now send specific messageKeysen/backend.jsonandja/backend.jsonfor errors that had no existing frontend translationWithMessageKey()are unaffected — they fall back to the defaultErrorTypestring