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

CIP-0057 | Fix schema validation error (strict mode) #770

Merged
merged 1 commit into from
Mar 5, 2024

Conversation

Unisay
Copy link
Contributor

@Unisay Unisay commented Mar 1, 2024

This PR fixes a subtle mistake in the JSON schema that is caught by the popular JSON schema validator ajv:

Error: strict mode: missing type "object" for keyword "required" at "https://cips.cardano.org/cips/cip57/schemas/plutus-builtin.json#" (strictTypes)
    at checkStrictMode (/home/yura/projects/cardano/plutus/node_modules/ajv/dist/compile/util.js:174:15)
    at strictTypesError (/home/yura/projects/cardano/plutus/node_modules/ajv/dist/compile/validate/index.js:286:32)
    at checkKeywordTypes (/home/yura/projects/cardano/plutus/node_modules/ajv/dist/compile/validate/index.js:262:17)
    at checkStrictTypes (/home/yura/projects/cardano/plutus/node_modules/ajv/dist/compile/validate/index.js:234:5)
    at schemaKeywords (/home/yura/projects/cardano/plutus/node_modules/ajv/dist/compile/validate/index.js:189:9)
    at typeAndKeywords (/home/yura/projects/cardano/plutus/node_modules/ajv/dist/compile/validate/index.js:128:5)
    at /home/yura/projects/cardano/plutus/node_modules/ajv/dist/compile/validate/index.js:70:9
    at CodeGen.code (/home/yura/projects/cardano/plutus/node_modules/ajv/dist/compile/codegen/index.js:439:13)
    at /home/yura/projects/cardano/plutus/node_modules/ajv/dist/compile/validate/index.js:37:166
    at CodeGen.code (/home/yura/projects/cardano/plutus/node_modules/ajv/dist/compile/codegen/index.js:439:13)

See the context and example here: ajv-validator/ajv#1553 (comment)

I've added explicit "type": "object" in a few places and it fixes the validation error.

@rphair
Copy link
Collaborator

rphair commented Mar 1, 2024

@Unisay this commit history includes c65b5dd from your earlier #768. That commit should be removed or reverted in this branch so these two PR's can be considered separately.

@rphair rphair changed the title CIP-0057 | Fix the schema validation error: strict mode: missing type "object" for keyword "required" CIP-0057 | Fix schema validation error (strict mode) Mar 1, 2024
@rphair rphair added the Correction Fixing minor issue or typo label Mar 1, 2024
@Unisay
Copy link
Contributor Author

Unisay commented Mar 1, 2024

That commit should be removed or reverted in this branch so these two PR's can be considered separately.

@rphair done!

@Ryun1
Copy link
Collaborator

Ryun1 commented Mar 2, 2024

Any chance this could break backwards compatibility?

@rphair rphair added the Category: Metadata Proposals belonging to the 'Metadata' category. label Mar 2, 2024
@Unisay
Copy link
Contributor Author

Unisay commented Mar 3, 2024

Any chance this could break backwards compatibility?

The only possibility I can imagine is that somebody relied on the fact that without explicit "type": "object" any value that is not an object was valid against the schema, which is highly unlikely.

Copy link
Collaborator

@rphair rphair left a comment

Choose a reason for hiding this comment

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

This seems logical & isn't believed by our CIP meeting attendees now to be likely to break anything.

Copy link
Collaborator

@Ryun1 Ryun1 left a comment

Choose a reason for hiding this comment

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

This seems unlikely to cause an issue with backwards compatibility, lets merge :)

@rphair rphair merged commit cf54d51 into cardano-foundation:master Mar 5, 2024
@Unisay Unisay deleted the strict-mode-fix branch March 6, 2024 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Metadata Proposals belonging to the 'Metadata' category. Correction Fixing minor issue or typo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants