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(json-schema-validator): propertly handle unknown definition #4745

Merged
merged 2 commits into from
Jan 16, 2024
Merged
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
10 changes: 8 additions & 2 deletions src/plugins/json-schema-validator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,15 @@ export const validateImmediate = ({ spec, path = [] }) => system => {
// schemaPath refers to type of schema, and later might refer to sub-schema
const baseSchemaPath = system.jsonSchemaValidatorSelectors.getSchemaBasePath()

// No base path? Then we're unable to do anything...
if (!baseSchemaPath.length)
// Ambiguous schema path
if (Array.isArray(baseSchemaPath) && baseSchemaPath.length === 0) {
throw new Error("Ambiguous schema path, unable to run validation")
}
// No base path? Then we're unable to do anything...
if (typeof baseSchemaPath === "undefined") {
system.log.warn("No base schema path found, unable to run validation")
return
}

return system.jsonSchemaValidatorActions.validateWithBaseSchema({
spec,
Expand Down
Loading