Skip to content

fix(functions): clearer schema errors for array items and oneOf/anyOf - #3095

Merged
Mateusz Wroński (kopernic-pl) merged 1 commit into
developfrom
chore/better-errors
Oct 22, 2026
Merged

Mateusz Wroński (kopernic-pl) merged 1 commit into
developfrom
chore/better-errors

Conversation

@kopernic-pl

Copy link
Copy Markdown
Contributor

Summary

Follow-up to the error-message review in #1072 (closed). Re-running its repros showed most were already fixed; this addresses the one that still read badly (array example failing a `oneOf`).

  • Array indexes are now described as items: `"1" property must have required property "url"` becomes `Item at index 1 must have required property "url"`, and `"0" property type must be string` becomes `Item at index 0 must be string`.
  • `oneOf`/`anyOf` failures where no schema matched now say so and point at the other errors for the value. Cases where several schemas matched are left unchanged.

The change is in the `schema` function's result mapper, since the wording comes from `@stoplight/[email protected]`, which has no newer release. The upstream `better-ajv-errors` 3.x has a different API and message format, so I did not migrate.

Not addressed

Testing

  • Added tests in `packages/functions/src/tests/schema.test.ts`; updated expectations in `asyncApiDocumentSchema.test.ts`.
  • `yarn jest packages/functions packages/rulesets`: only the four `oas3-schema › oas3.2` tests fail, and they fail identically without this change.

Array indexes were reported as properties (`"1" property must ...`) and
oneOf/anyOf failures gave no hint that the other errors explain the mismatch.

Refs #1072
@kopernic-pl
Mateusz Wroński (kopernic-pl) merged commit 5c566df into develop Oct 22, 2026
10 checks passed
@kopernic-pl
Mateusz Wroński (kopernic-pl) deleted the chore/better-errors branch October 22, 2026 11:42
Stoplighticus Roboticus (stoplight-bot) pushed a commit that referenced this pull request Nov 6, 2026
## @stoplight/spectral-functions [1.11.1](https://github.com/stoplightio/spectral/compare/@stoplight/spectral-functions-1.11.0...@stoplight/spectral-functions-1.11.1) (2026-11-06)

### Bug Fixes

* **functions:** clearer schema errors for array items and oneOf/anyOf ([#3095](#3095)) ([5c566df](5c566df)), closes [#1072](#1072)
* **functions:** republish 1.11.1 after failed release ([#3104](#3104)) ([d5da3c0](d5da3c0))
Stoplighticus Roboticus (stoplight-bot) pushed a commit that referenced this pull request Nov 6, 2026
## [6.17.1](https://github.com/stoplightio/spectral/compare/@stoplight/spectral-cli-6.17.0...@stoplight/spectral-cli-6.17.1) (2026-11-06)

### Bug Fixes

* **cli:** lint files whose names contain glob characters ([#3101](#3101)) ([bf782be](bf782be)), closes [#2814](#2814)
* **cli:** switch binary target to node22 ([#3080](#3080)) ([1355fa6](1355fa6))
* **core:** resolve a redefined rule's given against the aliases of its ruleset ([#3089](#3089)) ([6497ddd](6497ddd)), closes [#3085](#3085)
* **functions:** clearer schema errors for array items and oneOf/anyOf ([#3095](#3095)) ([5c566df](5c566df)), closes [#1072](#1072)
* **functions:** republish 1.11.1 after failed release ([#3104](#3104)) ([d5da3c0](d5da3c0))
* **rulesets:** guard null definitions in oas2-discriminator given ([#3098](#3098)) ([74a5fe0](74a5fe0))
* **rulesets:** relaxRequired does not traverse "not" schemas ([#3083](#3083)) ([95ab37e](95ab37e)), closes [#3068](#3068)
@stoplight-bot

Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 1.11.1 🎉

The release is available on @stoplight/spectral-functions-1.11.1

Your semantic-release bot 📦🚀

Stoplighticus Roboticus (stoplight-bot) pushed a commit that referenced this pull request Nov 6, 2026
## [1.24.1](https://github.com/stoplightio/spectral/compare/@stoplight/spectral-core-1.24.0...@stoplight/spectral-core-1.24.1) (2026-11-06)

### Bug Fixes

* **cli:** lint files whose names contain glob characters ([#3101](#3101)) ([bf782be](bf782be)), closes [#2814](#2814)
* **cli:** switch binary target to node22 ([#3080](#3080)) ([1355fa6](1355fa6))
* **core:** resolve a redefined rule's given against the aliases of its ruleset ([#3089](#3089)) ([6497ddd](6497ddd)), closes [#3085](#3085)
* **functions:** clearer schema errors for array items and oneOf/anyOf ([#3095](#3095)) ([5c566df](5c566df)), closes [#1072](#1072)
* **functions:** republish 1.11.1 after failed release ([#3104](#3104)) ([d5da3c0](d5da3c0))
* **rulesets:** guard null definitions in oas2-discriminator given ([#3098](#3098)) ([74a5fe0](74a5fe0))
* **rulesets:** relaxRequired does not traverse "not" schemas ([#3083](#3083)) ([95ab37e](95ab37e)), closes [#3068](#3068)
Stoplighticus Roboticus (stoplight-bot) pushed a commit that referenced this pull request Nov 6, 2026
## [1.23.1](https://github.com/stoplightio/spectral/compare/@stoplight/spectral-rulesets-1.23.0...@stoplight/spectral-rulesets-1.23.1) (2026-11-06)

### Bug Fixes

* **cli:** lint files whose names contain glob characters ([#3101](#3101)) ([bf782be](bf782be)), closes [#2814](#2814)
* **cli:** switch binary target to node22 ([#3080](#3080)) ([1355fa6](1355fa6))
* **core:** resolve a redefined rule's given against the aliases of its ruleset ([#3089](#3089)) ([6497ddd](6497ddd)), closes [#3085](#3085)
* **functions:** clearer schema errors for array items and oneOf/anyOf ([#3095](#3095)) ([5c566df](5c566df)), closes [#1072](#1072)
* **functions:** republish 1.11.1 after failed release ([#3104](#3104)) ([d5da3c0](d5da3c0))
* **rulesets:** guard null definitions in oas2-discriminator given ([#3098](#3098)) ([74a5fe0](74a5fe0))
* **rulesets:** relaxRequired does not traverse "not" schemas ([#3083](#3083)) ([95ab37e](95ab37e)), closes [#3068](#3068)

### Features

* **repo:** minor release trigger ([#3079](#3079)) ([eabafec](eabafec))
Mateusz Wroński (kopernic-pl) pushed a commit to smsalisbury/spectral that referenced this pull request Nov 12, 2026
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.

3 participants