-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: add rfc for move i18n logic to frontend #1436
base: main
Are you sure you want to change the base?
Conversation
dt, err := statusEmailIsEmpty.WithDetails( | ||
&errdetails.ErrorInfo{ | ||
Reason: "INVALID", | ||
Domain: "account.bucketeer.io", | ||
Metadata: map[string]string{ | ||
"messageKey": "account.invalid.empty", | ||
"feild": "email", | ||
}, | ||
}) | ||
if err != nil { | ||
return statusInternal.Err() | ||
} | ||
return dt.Err() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to put this log logic into a common function.
Depending on the function, we handle many errors, making the function too long.
One of the reasons for moving the localizer to the front end is also to improve code readability.
WDYT?
dt, err := statusEmailIsEmpty.WithDetails( | |
&errdetails.ErrorInfo{ | |
Reason: "INVALID", | |
Domain: "account.bucketeer.io", | |
Metadata: map[string]string{ | |
"messageKey": "account.invalid.empty", | |
"feild": "email", | |
}, | |
}) | |
if err != nil { | |
return statusInternal.Err() | |
} | |
return dt.Err() | |
return error.NewError(...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, Good idea!
It's certainly more readable that way, so I do that when coding.
``` | ||
|
||
## Release Steps | ||
1. Releases a process that returns an ErrorInfo for each package for The backend. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically, we will use canary release to switch i18n logic from backend to fronted, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's right. Bucketeer essentially uses a canary release.
&errdetails.ErrorInfo{ | ||
Reason: "INVALID", | ||
Domain: "account.bucketeer.io", | ||
Metadata: map[string]string{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering if we can add multiple error metadata, e.g.
[]map[string]string{
{
"messageKey": "account.invalid.empty",
"field": "email",
},
{
"messageKey": "account.invalid.empty",
"field": "phone_number",
},
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although it is stated in the RFC, it uses GRPC's ErrorInfo, so the type of Metadata cannot be changed.
If multiple errors are returned, we plan to return multiple ErrorInfo's.
dt, err := statusEmailIsEmpty.WithDetails(
&errdetails.LocalizedMessage{
Locale: localizer.GetLocale(),
Message: localizer.MustLocalizeWithTemplate(locale.InvalidArgumentError, "email"),
},
&errdetails.ErrorInfo{
Reason: "INVALID",
Domain: "account.bucketeer.io",
Metadata: map[string]string{
"messageKey": "account.invalid.empty",
"feild": "email",
},
},
&errdetails.ErrorInfo{
Reason: "INVALID",
Domain: "account.bucketeer.io",
Metadata: map[string]string{
"messageKey": "account.invalid.empty",
"feild": "phone_number",
},
})
This pull request proposes moving the i18n (internationalization) logic entirely to the frontend to simplify the backend code. The changes include adding detailed documentation and examples of the new error handling design using GRPC's
ErrorInfo
and removing the existingLocalizedMessage
code from the backend.#1253