Skip to content

Conversation

250MHz
Copy link
Contributor

@250MHz 250MHz commented Jun 19, 2025

Description

  • Start "key" with an array index when the validation error applies to a request body or a query parameter that is a list.

  • Use alternative name for query parameters, cookies, and headers in "key" instead of the parameter's name in a route handler's signature.

  • Parameters in route handlers that are not the request body but whose names start with "data" will not have their validation error message "source" set to "body".

  • Use a "key" that better resembles the format that msgspec uses when an ExtendedMsgSpecValidationError is raised.

Closes

Closes #4215

@250MHz 250MHz requested review from a team as code owners June 19, 2025 06:18
@github-actions github-actions bot added area/private-api This PR involves changes to the privatized API area/signature size: small type/feat pr/external Triage Required 🏥 This requires triage labels Jun 19, 2025
@250MHz 250MHz force-pushed the improve-validation-error-key branch from 04894df to 3f30198 Compare June 19, 2025 06:19
@250MHz 250MHz changed the title feat: improve "key" property in valiation error messages feat: improve "key" property in validation error messages Jun 19, 2025
Copy link

codecov bot commented Jun 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.39%. Comparing base (ce67b6f) to head (7563095).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4216   +/-   ##
=======================================
  Coverage   98.38%   98.39%           
=======================================
  Files         348      348           
  Lines       15895    15922   +27     
  Branches     1756     1764    +8     
=======================================
+ Hits        15638    15666   +28     
  Misses        121      121           
+ Partials      136      135    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

* Start "key" with an array index when the validation error applies to a
  request body or a query parameter that is a list.

* Use alternative name for query parameters, cookies, and headers in
  "key" instead of the parameter's name in a route handler's signature.

* Parameters in route handlers that are not the request body but whose
  names start with "data" will not have their validation error message
  "source" set to "body".

* Use a "key" that better resembles the format that msgspec uses when an
  ExtendedMsgSpecValidationError is raised.
@250MHz 250MHz force-pushed the improve-validation-error-key branch from 3f30198 to 7563095 Compare June 19, 2025 07:31
Copy link

Documentation preview will be available shortly at https://litestar-org.github.io/litestar-docs-preview/4216

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/private-api This PR involves changes to the privatized API area/signature pr/external size: small Triage Required 🏥 This requires triage type/feat
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement: Improve "key" property of validation error messages
1 participant