Skip to content

fix: resolve schema validation bug where errors were swallowed - #2831

Open
karansaini46 wants to merge 1 commit into
stoplightio:masterfrom
karansaini46:fix/schema-validation-error-swallowed
Open

fix: resolve schema validation bug where errors were swallowed#2831
karansaini46 wants to merge 1 commit into
stoplightio:masterfrom
karansaini46:fix/schema-validation-error-swallowed

Conversation

@karansaini46

Copy link
Copy Markdown

Closes #2442.

What was the problem?
When providing an invalid OpenAPI schema (e.g. type: obj), the validation proxy was silently swallowing the Ajv compilation error and proceeding to pass the request/response validation. The issue stems from the use of O.tryCatch, which caught the schema error but simply returned O.none, meaning 'no errors'.

What changed?
Refactored validateAgainstSchema to use E.tryCatch so we capture the error from Ajv compilation instead of losing it. The error is now correctly folded into an IPrismDiagnostic with a severity of Error and a generic code 500. Also added a regression test for invalid schema objects.

Why this approach was chosen?
Using E.tryCatch keeps the functional programming approach consistent while exposing the error properly as an array of Prism Diagnostics, matching the expected return type and reporting to the user properly.

This fixes issue stoplightio#2442 where an invalid schema would cause the validation proxy to always pass silently because the compilation error from Ajv was swallowed by O.tryCatch.
@karansaini46
karansaini46 requested a review from a team as a code owner July 18, 2026 07:56
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.

An invalid schema will cause the validation proxy to always pass

1 participant