Skip to content

[DGR-4735] Document the 422 for credential recipient assignment - #139

Open
sandilya91 wants to merge 1 commit into
developfrom
DGR-4735-credential-assignment-422
Open

[DGR-4735] Document the 422 for credential recipient assignment#139
sandilya91 wants to merge 1 commit into
developfrom
DGR-4735-credential-assignment-422

Conversation

@sandilya91

@sandilya91 sandilya91 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

What & why

POST /v1/credentials and POST /v1/credentials/bulk_create can fail with a 422 ("Could not assign user to the credential", raised by the Credential#assign_user hook when recipient-account creation fails or two requests race on the same recipient_email), but neither endpoint documented any 422, so integrators had nothing to code against. This documents the 422 on both, including that the lock-race case is transient and worth retrying. Implements DGR-4735 / ISD-3046.

Review notes

  • Each endpoint's errors is modelled as a oneOf because the code genuinely returns two shapes: an attribute-keyed object (the ticket's case) or a plain string from the rescue branches. Both shapes already appear in the spec's global Errors section.
  • Found but deliberately left out; ask and I'll fold either in:
    • PUT /v1/credentials/{id} returns 400, not 422, for the same error, and documents no error responses at all. Wider gap than this ticket.
    • The documented 422 on POST /v2/credentials/bulk_create doesn't match Services::CredentialBulkCreateSerializer (errors with message vs error with reason). Pre-existing.

Testing

  • Rendered in Redoc locally; checked description, schema and response sample on both operations.
  • redocly lint vs develop: errors unchanged at 135, warnings 159 → 157. The two resolved warnings are exactly the operation-4xx-response warnings for these two operations.

Creating a Credential can fail validation with a `user` error of
"Could not assign user to the credential", raised when we cannot attach
a recipient account to the Credential. Neither creation endpoint
documented a 422 at all, so integrators had nothing to code against.

Adds the 422 to POST /v1/credentials and POST /v1/credentials/bulk_create,
covering both shapes `errors` actually takes on each: attribute-keyed
validation messages (an object for single create, an array with one entry
per failed Credential for bulk) or a single message string when the
request could not be processed at all.

The description calls out that the advisory-lock timeout behind this
error is transient, so retrying is the right response.

Implements ISD-3046.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@sandilya91
sandilya91 marked this pull request as ready for review August 5, 2026 13:41
@sandilya91 sandilya91 self-assigned this Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant