Repository navigation
Reject an invalid schema every time it's validated - #134
Merged
jdesrosiers merged 1 commit intoOct 14, 2026
Merged
Conversation
jdesrosiers
approved these changes
Oct 14, 2026
Contributor
Author
|
@jdesrosiers Is there anything specific you'd like help with? Otherwise I'll keep doing what I did here: find bugs, open an issue with a repro, and send a fix once you're OK with it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #133
The meta-validation subscriber marks a schema as validated before checking it, and the mark stayed in place when the check failed. So only the first
validatecall threwInvalidSchemaError; later calls used the invalid schema, or crashed (TypeError: type.some is not a functionfortype: 5).The mark still has to be set before checking, because a meta-schema validates against itself. I tried setting it only after a successful check, and Node aborted with infinite recursion. So it stays where it is, and it's now cleared if validation fails or anything in it throws (including loading or compiling the meta-schema). The schema is then validated again on the next call.
Tests
Added
lib/meta-validation.spec.tswith two cases from the issue: validating an invalid schema twice, and validating after a failed compile. Both fail onmainand pass with this change.npm test(15,001 passed), lint andtsc --noEmitare all clean.Not covered: if two
validatecalls for the same invalid schema run concurrently (e.g. inPromise.all), the second one still skips meta-validation while the first is in progress, so it can still hit theTypeError. That's the same as before this change. Fixing it would mean storing the in-progress validation and awaiting it instead of a boolean. Happy to do that here or in a follow-up if you want it, but I didn't want to widen the change without asking.