-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix(core): localize organization invitation validation errors #9353
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@logto/core': minor | ||
| --- | ||
|
Kathircpe marked this conversation as resolved.
|
||
|
|
||
| use dedicated i18n error codes for organization invitation validation errors | ||
|
|
||
| Organization invitation creation and status update errors previously returned the generic `request.invalid_input` code with English-only `details`. They now return specific, localized codes under the `organization` namespace: `invitee_already_member`, `expires_at_in_future`, `invitation_status_not_changeable`, `accepted_user_id_required`, and `accepted_user_email_mismatch`, so clients can reliably distinguish each failure case and messages render in the user's language. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,8 +68,7 @@ export class OrganizationInvitationLibrary { | |
| if (await this.queries.organizations.relations.users.isMember(organizationId, invitee)) { | ||
| throw new RequestError({ | ||
| status: 422, | ||
| code: 'request.invalid_input', | ||
| details: 'The invitee is already a member of the organization.', | ||
| code: 'organization.invitee_already_member', | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For existing Management API clients that branch on AGENTS.md reference: AGENTS.md:L37-L37 Useful? React with 👍 / 👎.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These five replacements remove error codes that released endpoints have been returning, so any client branching on |
||
| }); | ||
| } | ||
|
|
||
|
|
@@ -152,7 +151,7 @@ export class OrganizationInvitationLibrary { | |
| status: OrganizationInvitationStatus.Accepted, | ||
| acceptedUserId: string | ||
| ): Promise<OrganizationInvitationEntity>; | ||
| // TODO: Error i18n | ||
|
|
||
| async updateStatus( | ||
|
Kathircpe marked this conversation as resolved.
|
||
| id: string, | ||
| status: OrganizationInvitationStatus, | ||
|
|
@@ -163,8 +162,7 @@ export class OrganizationInvitationLibrary { | |
| if (endingStatuses.includes(entity.status)) { | ||
| throw new RequestError({ | ||
| status: 422, | ||
| code: 'request.invalid_input', | ||
| details: 'The status of the invitation cannot be changed anymore.', | ||
| code: 'organization.invitation_status_not_changeable', | ||
| }); | ||
| } | ||
|
|
||
|
|
@@ -184,8 +182,7 @@ export class OrganizationInvitationLibrary { | |
| if (user.primaryEmail?.toLowerCase() !== entity.invitee.toLowerCase()) { | ||
| throw new RequestError({ | ||
| status: 422, | ||
| code: 'request.invalid_input', | ||
| details: 'The accepted user must have the same email as the invitee.', | ||
| code: 'organization.accepted_user_email_mismatch', | ||
| }); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,8 +77,7 @@ export default function organizationInvitationRoutes<T extends ManagementApiRout | |
| assertThat( | ||
| body.expiresAt > Date.now(), | ||
| new RequestError({ | ||
| code: 'request.invalid_input', | ||
| details: 'The value of `expiresAt` must be in the future.', | ||
| code: 'organization.expires_at_in_future', | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Management API consumers consult or generate clients from AGENTS.md reference: AGENTS.md:L39-L39 Useful? React with 👍 / 👎.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The 400/422 descriptions in |
||
| }) | ||
| ); | ||
|
Kathircpe marked this conversation as resolved.
|
||
|
|
||
|
|
@@ -149,13 +148,11 @@ export default function organizationInvitationRoutes<T extends ManagementApiRout | |
| return next(); | ||
| } | ||
|
|
||
| // TODO: Error i18n | ||
| assertThat( | ||
| acceptedUserId, | ||
| new RequestError({ | ||
| status: 422, | ||
| code: 'request.invalid_input', | ||
| details: 'The `acceptedUserId` is required when accepting an invitation.', | ||
| code: 'organization.accepted_user_id_required', | ||
| }) | ||
| ); | ||
|
|
||
|
|
||
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.
For npm consumers of
@logto/phrases, this changeset versions only@logto/core, sochangeset versionleaves the publishable phrases package at its existing version and the repository'spnpm -r publishinvocation has no--force;pnpm publish --helpconfirms that already-registered package versions are processed only with that flag. Consequently, the new locale resources and exportedLogtoErrorCodemembers will not be published; add an@logto/phrasespatch entry to the changeset.AGENTS.md reference: AGENTS.md:L19-L21
Useful? React with 👍 / 👎.