You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Document the real 422 bodies and the nullable campaign sender name - #72
Several error responses in the Account Management, Email Campaigns and Email Sending references don't match what the API returns. Some 422 bodies have a different errors shape, three operations don't list their 422 at all, and a campaign's from_display_name can be null. Clients generated from these documents decode those responses wrongly.
Changes
Account Management
Bulk permission updates return errors as a single message.
Creating an API token returns either messages per attribute (the token's own validation, such as no permissions or the active-token limit) or a single message (an invalid permission, such as an unknown resource). It is documented as a oneOf with an example of each.
Creating a sub account returns errors as an array of messages.
Deleting an account access lists its 422: the account owner's access can't be removed.
Email Campaigns
Start and schedule get their own 422: a single message (an invalid transition or datetime) or sending-validation messages per attribute, campaign-wide ones under base. The documented array never occurs.
Cancel, terminate and reset keep the shared 422, narrowed to a single message.
Listing campaigns lists its 422 for an out-of-range token, as listing templates already does.
from_display_name is null for a campaign without a sender name.
Email Sending
Domain setup instructions return one message per key (email or base), not arrays.
Deleting a domain lists its 422 for a domain that inbound inboxes still use.
This touches the same responses: blocks as #71 and sits next to the code samples #69 edits; whichever lands second rebases.
How to test
You'll need an admin API token for an account with a sending domain and email campaigns, and an organization API token for the sub-account checks. Each response below should match what the API reference now documents for that operation.
Account Management
Owner permissions: PUT /api/account_accesses/{owner_access_id}/permissions/bulk with any permission. Expect 422, {"errors":"You can't update the permissions of an account owner"}.
Token without permissions: POST /api/api_tokens with an empty resources list. Expect 422, {"errors":{"base":["No permissions selected. Please choose at least one."]}}.
Token with an unknown resource: POST /api/api_tokens with {"resource_type":"project","resource_id":<missing id>,"access_level":100} in resources. Expect 422, {"errors":"Resource of type 'project' and ID #<id> not found"}.
Owner access delete: DELETE /api/account_accesses/{owner_access_id}. Expect 422, {"errors":"You can not remove the owner of the account"}.
Sub-account limit: POST /api/organizations/{organization_id}/sub_accounts for an organization at its sub-account limit. Expect 422, {"errors":["Accounts limit reached"]}. A name over 80 characters returns {"errors":["Failed to create account."]}.
Email Campaigns
Start, sending validation fails: POST /api/email_campaigns/{id}/start on a draft of an account with no company information. Expect 422 with the message under errors.base as an array.
Start, invalid transition: start a campaign that is already started. Expect 422, {"errors":"Cannot transition from 'started' to 'scheduled'"}.
Schedule: the same two cases on POST /api/email_campaigns/{id}/schedule give the same two shapes.
Cancel, terminate, reset: each from a state that doesn't allow it returns a single message, e.g. cancelling a draft gives {"errors":"Campaign is not scheduled"}.
List, token out of range: GET /api/email_campaigns?per_page=100&token=100000000000000000. Expect 422, {"errors":"token is out of range"}.
No sender name: GET /api/email_campaigns/{id} for a campaign created without from_display_name. Expect 200 with "from_display_name": null.
Email Sending
Setup instructions, invalid email: POST /api/domains/{domain_id}/send_setup_instructions with {"email":"invalid"}. Expect 422, {"errors":{"email":"Invalid email address"}}.
Domain delete, inbound inbox uses it: DELETE /api/domains/{domain_id} for a domain an inbound inbox depends on. Expect 422, {"errors":{"base":["Can't delete the domain because there are inbound inboxes depending on it."]}}.
Summary by CodeRabbit
Documentation
Expanded API documentation with specific 422 error cases for account management, including permission changes, token creation, and sub-account creation.
Clarified email campaign validation responses for pagination, sending, and lifecycle actions, and documented nullable sender display names.
Added email-sending error details for invalid setup addresses, blocked domains, and domains that cannot be deleted while inbound inboxes depend on them.
Decisions:
- Describe each 422 by the body the API renders: a string, an array, or per-attribute strings, where the documents claimed per-attribute arrays
- Add the 422s that deleting an account access, listing campaigns and deleting a domain return but did not list
- Split start/schedule from cancel/terminate/reset: only the first two return sending-validation errors, and no action returns a plain array
- Keep the per-attribute response component for API token reset, which still renders that shape
- from_display_name is null for a campaign without a sender name
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This repository does not receive automatic reviews because it has fewer than 10 stars.
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 7cd672f8-c037-4bc0-8298-b816113851cb
No actionable comments were generated in the recent review.
Walkthrough
The OpenAPI specifications add endpoint-specific error responses and examples for account management, email campaigns, and email sending. Campaign documentation also permits a null from_display_name and separates lifecycle action errors from sending-validation errors.
Start and schedule use a sending-specific error response. Lifecycle errors use a single-message shape; sending errors also support attribute-based validation errors.
Email sending
Layer / File(s)
Summary
Domain and setup-instruction errors specs/email-sending.openapi.yml
Domain deletion documents the inbound-inbox dependency that blocks deletion. Setup instructions document invalid email and blocked-domain errors.
This PR documents API error responses and a nullable field in the OpenAPI specifications. It changes no runtime behavior, and no merge-blocking issue was found.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the two main themes: documenting the real 422 response bodies and the nullable campaign sender name. It is specific and matches the changes in the three OpenAPI spec files. It does not…
Description check
The description follows the repository template's Motivation and Changes sections, and it adds a detailed How to test section with concrete request and response checks. It has no Images and GIFs secti…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the two main themes: documenting the real 422 response bodies and the nullable campaign sender name. It is specific and matches the changes in the three OpenAPI spec files. It does not cover the Account Management and Email Sending changes, which the description allows.
Full details: Description check
Explanation
The description follows the repository template's Motivation and Changes sections, and it adds a detailed How to test section with concrete request and response checks. It has no Images and GIFs section, and it does not fill the template placeholders. That section fits a spec-only change with no visual output, so this gap is not critical. The description also says the change overlaps PR #71 and needs a rebase, which is useful context.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 55f01c02-1e70-449b-a94b-d8909e135eaf
Commits
Reviewing files that changed from the base of the PR and between 4e6814d and 923beb9.
Files selected for processing: 2
specs/account-management.openapi.yml
specs/email-campaigns.openapi.yml
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.
Decisions:
- Start and schedule 422 is a oneOf of the existing single-message and per-attribute schemas, as the API token create 422 is, instead of a third schema that copied both.
- The bulk permission, API token and sub-account 422 descriptions now name every cause the API returns them for: an invalid access level, an update that leaves no permissions, an organization scheduled for deletion.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.
Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.
Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.
Decisions:
- A permission update that would leave billing as the only permission in an organization without the Organizations and Sub-Accounts feature returns a single-message 422; API tokens can't hold billing, so the token create 422 doesn't list it
- The schemas used as oneOf branches require errors, so a body can't match both branches
- Sending-validation messages always come under base, not per attribute
- The datetime error only applies to scheduling, since start takes no datetime
- from_display_name and the Reply-To display_name accept and return null, in requests as in responses
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Decisions:
- A missing or empty account.name reaches Rails' default 400 body, {"status":400,"error":"Bad Request"}, which has no errors key and stopped matching ErrorResponse once errors became required
- BadRequest mirrors the Email Sending document's schema of the same name, plus the status the body carries
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Decisions:
- The backend always wraps these 422 bodies as { errors: ... }, so generated clients get a non-optional field, as with the named error schemas
- The templates list 422 changes with the campaigns one so the two stay identical
- email-sending's UnprocessableEntity backs the new delete-domain 422, and every 422 that uses it renders errors, so it requires errors as its account-management counterpart does
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
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.
Motivation
Several error responses in the Account Management, Email Campaigns and Email Sending references don't match what the API returns. Some 422 bodies have a different
errorsshape, three operations don't list their 422 at all, and a campaign'sfrom_display_namecan benull. Clients generated from these documents decode those responses wrongly.Changes
errorsas a single message.oneOfwith an example of each.errorsas an array of messages.datetime) or sending-validation messages per attribute, campaign-wide ones underbase. The documented array never occurs.token, as listing templates already does.from_display_nameisnullfor a campaign without a sender name.emailorbase), not arrays.This touches the same
responses:blocks as #71 and sits next to the code samples #69 edits; whichever lands second rebases.How to test
You'll need an admin API token for an account with a sending domain and email campaigns, and an organization API token for the sub-account checks. Each response below should match what the API reference now documents for that operation.
Account Management
PUT /api/account_accesses/{owner_access_id}/permissions/bulkwith any permission. Expect422,{"errors":"You can't update the permissions of an account owner"}.POST /api/api_tokenswith an emptyresourceslist. Expect422,{"errors":{"base":["No permissions selected. Please choose at least one."]}}.POST /api/api_tokenswith{"resource_type":"project","resource_id":<missing id>,"access_level":100}inresources. Expect422,{"errors":"Resource of type 'project' and ID #<id> not found"}.DELETE /api/account_accesses/{owner_access_id}. Expect422,{"errors":"You can not remove the owner of the account"}.POST /api/organizations/{organization_id}/sub_accountsfor an organization at its sub-account limit. Expect422,{"errors":["Accounts limit reached"]}. A name over 80 characters returns{"errors":["Failed to create account."]}.Email Campaigns
POST /api/email_campaigns/{id}/starton a draft of an account with no company information. Expect422with the message undererrors.baseas an array.422,{"errors":"Cannot transition from 'started' to 'scheduled'"}.POST /api/email_campaigns/{id}/schedulegive the same two shapes.{"errors":"Campaign is not scheduled"}.GET /api/email_campaigns?per_page=100&token=100000000000000000. Expect422,{"errors":"token is out of range"}.GET /api/email_campaigns/{id}for a campaign created withoutfrom_display_name. Expect200with"from_display_name": null.Email Sending
POST /api/domains/{domain_id}/send_setup_instructionswith{"email":"invalid"}. Expect422,{"errors":{"email":"Invalid email address"}}.DELETE /api/domains/{domain_id}for a domain an inbound inbox depends on. Expect422,{"errors":{"base":["Can't delete the domain because there are inbound inboxes depending on it."]}}.Summary by CodeRabbit
422error cases for account management, including permission changes, token creation, and sub-account creation.