Skip to content

feat(errors): Error400.details.errors[] array for multi-field validation - #764

Merged
akanter merged 2 commits into
mainfrom
07-29-error400-errors-array
Jul 29, 2026
Merged

feat(errors): Error400.details.errors[] array for multi-field validation#764
akanter merged 2 commits into
mainfrom
07-29-error400-errors-array

Conversation

@akanter

@akanter akanter commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Replaces singular details.field + details.constraint on Error400 with a typed details.errors[] array so submit endpoints (POST /customers, PATCH /customers/{id}) can report every invalid field in one round-trip.

Motivation

The consumer implementation on the sparkcore side (webdev#31110) iterates all pydantic errors and emits one entry per invalid field. The spec previously only surfaced the first as machine-readable — platform integrators would have to re-submit and see the next one on each round-trip. The array shape lets them render form-field-level UX for the whole request in one shot.

Changes: 4 files

  • openapi/components/schemas/errors/FieldError.yaml — new schema: {field: required string, constraint?: FieldConstraint, message?: string}. One entry per invalid field.
  • openapi/components/schemas/errors/Error400.yamldetails now has errors: array of FieldError; drops the singular field and constraint properties.
  • openapi.yaml + mintlify/openapi.yaml — regenerated bundles (make build).

Breaking change

details.field and details.constraint are removed at the top level of details. Approved per lightsparkdev/webdev#31110 review — no external consumers had wired the previous shape into production yet, so this is safe to change in place.

Skipping the info.version bump on that basis; happy to add one if reviewers prefer.

Downstream consumer

The sparkcore side lives in lightsparkdev/webdev#31110. After this lands, that PR will regenerate the grid-api Python client and drop its backwards-compat singular field/constraint carriage on GridException.

Requested by @akanter

Original PR: #763

Replace singular `details.field`/`details.constraint` with a typed
`details.errors[]` array so submit endpoints (POST /customers, PATCH
/customers/{id}) can report every invalid field in one round-trip.

Adds `FieldError` schema — one entry per invalid field, carrying
`field` (dot-notation path), optional `constraint` (FieldConstraint —
the existing machine-readable validator hint), and optional `message`
(human-readable explanation).

Backwards-incompatible change to `Error400.details`: the singular
`field` and `constraint` properties are removed. Approved per
lightsparkdev/webdev#31110 review — no consumers of the previous shape
had wired it into production yet.

Consumers of this shape land in webdev#31110.

akanter commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

✱ Stainless preview builds for grid

This PR will update the grid SDKs with the following commit messages.

cli

chore(internal): regenerate SDK with no functional changes

go

chore(internal): regenerate SDK with no functional changes

kotlin

chore(internal): regenerate SDK with no functional changes

openapi

feat(api): add FieldError model and errors array to Error422 details

php

chore(internal): regenerate SDK with no functional changes

python

chore(internal): regenerate SDK with no functional changes

ruby

chore(internal): regenerate SDK with no functional changes

typescript

chore(internal): regenerate SDK with no functional changes
⚠️ grid-openapi studio · code

Your SDK build had at least one "warning" diagnostic.
generate ⚠️

grid-ruby studio · code

Your SDK build had at least one "note" diagnostic.
generate ✅build ⏭️lint ✅test ✅

⚠️ grid-go studio · code

Your SDK build had a failure in the lint CI job, which is a regression from the base state.
generate ✅build ⏭️lint ❗test ❗

go get github.com/stainless-sdks/grid-go@0c9d582b0930615d5bbc7e9d63e36a4561263984
⚠️ grid-kotlin studio · code

Your SDK build had a failure in the test CI job, which is a regression from the base state.
generate ⚠️build ⏭️lint ⏭️test ❗

⚠️ grid-python studio · code

Your SDK build had a failure in the test CI job, which is a regression from the base state.
generate ✅build ⏭️lint ⏭️test ❗

grid-typescript studio · conflict

Your SDK build had at least one note diagnostic.

grid-php studio · code

Your SDK build had at least one "note" diagnostic.
generate ✅lint ✅test ✅

⚠️ grid-cli studio · code

Your SDK build had a failure in the test CI job, which is a regression from the base state.
generate ⚠️build ⏭️lint ⏭️test ❗


This comment is auto-generated by GitHub Actions and is automatically kept up to date as you push.
If you push custom code to the preview branch, re-run this workflow to update the comment.
Last updated: 2026-07-29 16:40:13 UTC

@akanter
akanter marked this pull request as ready for review July 29, 2026 07:18
Comment on lines +107 to +113
errors:
type: array
description: >-
Dot-notation path to the offending field. Present on field-validation
errors from submit endpoints.
example: taxIdentifier
constraint:
$ref: ./FieldConstraint.yaml
One entry per invalid field. Present on field-validation errors from
submit endpoints.
items:
$ref: ./FieldError.yaml

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Obsolete Error400 test fixture

The only repository test for Error400.details still constructs and asserts the removed { field: "email" } shape, so it provides no regression coverage for parsing the new errors array and nested FieldError properties. Update the fixture and assertion alongside this contract change.

Prompt To Fix With AI
This is a comment left during a code review.
Path: openapi/components/schemas/errors/Error400.yaml
Line: 107-113

Comment:
**Obsolete Error400 test fixture**

The only repository test for `Error400.details` still constructs and asserts the removed `{ field: "email" }` shape, so it provides no regression coverage for parsing the new `errors` array and nested `FieldError` properties. Update the fixture and assertion alongside this contract change.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — fixed in 06d7b8cb. Updated the cli/test/client.test.ts fixture and its assertion to use details: { errors: [{ field: "email" }] }, matching the new FieldError[] array contract. The test's behavior-under-test (CLI passes details through verbatim, and the whole error envelope is not nested under details) is unchanged.


🤖 staking-corona-30(#30) | Feedback

@greptile-apps

greptile-apps Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Updates the shared 400-error validation contract to return all field failures in one response.

  • Adds a reusable FieldError schema containing a required field path and optional constraint and message.
  • Replaces details.field and details.constraint with details.errors[].
  • Regenerates the synchronized root and Mintlify OpenAPI bundles.

Confidence Score: 4/5

The PR appears safe to merge, with the non-blocking caveat that its Error400 parsing fixture should be updated to cover the new array response.

The source schema and both generated bundles are internally consistent, but the only in-repository Error400 details test still exercises the removed singular field representation and therefore provides no regression coverage for the new nested array contract.

Files Needing Attention: openapi/components/schemas/errors/Error400.yaml and cli/test/client.test.ts

Important Files Changed

Filename Overview
openapi/components/schemas/errors/Error400.yaml Replaces singular field-validation details with an array, but the repository's corresponding parsing fixture remains on the removed shape.
openapi/components/schemas/errors/FieldError.yaml Adds a well-formed reusable field-level validation error schema with correctly resolved references.
openapi.yaml Correctly contains the resolved FieldError schema and updated Error400 contract generated from the modular source.
mintlify/openapi.yaml Remains synchronized with the root generated OpenAPI bundle.

Class Diagram

%%{init: {'theme': 'neutral'}}%%
classDiagram
  class Error400 {
    int status
    string code
    string message
    details
  }
  class ErrorDetails {
    FieldError[] errors
  }
  class FieldError {
    string field
    FieldConstraint constraint
    string message
  }
  class FieldConstraint {
    string format
    string pattern
    string[] enum
    int minLength
    int maxLength
  }
  Error400 --> ErrorDetails
  ErrorDetails --> FieldError
  FieldError --> FieldConstraint
Loading
Prompt To Fix All With AI
### Issue 1
openapi/components/schemas/errors/Error400.yaml:107-113
**Obsolete Error400 test fixture**

The only repository test for `Error400.details` still constructs and asserts the removed `{ field: "email" }` shape, so it provides no regression coverage for parsing the new `errors` array and nested `FieldError` properties. Update the fixture and assertion alongside this contract change.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "feat(errors): Error400.details.errors[] ..." | Re-trigger Greptile

Greptile flagged the fixture as stale: it constructed and asserted on
`details: { field: 'email' }` (the singular shape this PR removed).
Updated to `details: { errors: [{ field: 'email' }] }` so the test
exercises the new FieldError-array contract.

Behavior under test is unchanged (the CLI passes details through
verbatim); this just realigns the fixture with the current spec.
@vercel

vercel Bot commented Jul 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
grid-flow-builder Ignored Ignored Preview Jul 29, 2026 7:23am
grid-wallet-demo Ignored Ignored Preview Jul 29, 2026 7:23am

Request Review

akanter commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Merge activity

  • Jul 29, 4:33 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jul 29, 4:33 PM UTC: @akanter merged this pull request with Graphite.

@akanter
akanter merged commit 46ed99d into main Jul 29, 2026
12 checks passed
@akanter
akanter deleted the 07-29-error400-errors-array branch July 29, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants