Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rulesets): avoid false errors from ajv #2408

Merged
merged 5 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
"test.karma": "karma start",
"prepare": "husky install",
"prerelease": "patch-package",
"release": "yarn prerelease && yarn workspaces foreach run release"
"release": "yarn prerelease && yarn workspaces foreach run release",
"jest": "jest"
Copy link
Contributor Author

@padamstx padamstx Apr 10, 2023

Choose a reason for hiding this comment

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

Added the "jest" script so that it will be easier to run jest from the command line such that the version installed in node_modules will be used instead of whatever version of jest happens to be installed on a particular machine.

},
"workspaces": {
"packages": [
Expand Down
5 changes: 4 additions & 1 deletion packages/functions/src/schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ export default createRulesetFunction<unknown, Options>(
// let's ignore any $ref errors if schema fn is provided with already resolved content,
// if our resolver fails to resolve them,
// ajv is unlikely to do it either, since it won't have access to the whole document, but a small portion of it
if (!rule.resolved || !(ex instanceof MissingRefError)) {
// We specifically check that "rule" is truthy below because "rule" might be undefined/null if this
// code is called from testcases.
const ignoreError = rule?.resolved && ex instanceof MissingRefError;
if (!ignoreError) {
results.push({
message: ex.message,
path,
Expand Down
Loading