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

Handle registration of schemas with the same $id #60

Merged
merged 5 commits into from
Apr 29, 2021

Conversation

kiendang
Copy link
Member

@kiendang kiendang commented Apr 23, 2021

Raise a value error when attempting to register a schema with the same $id and version with another one that has already been registered.

Also allow register_schema_file to accept a file object as input. Would be useful for loading client schemas imported using importlib.resources which are returned as file objects.

outdated stuff below

This add options how to handle registering a schema having the same `$id` with another schema that has already been registered.

Currently if the input schema has the same $id and version as an existing schema, it would just override it. One situation where this is not ideal is the case of client events in jupyter-server/jupyter_server#364. A client can override and mimic a server event just by having the same $id and version.

This PR add a new argument duplicate to register_schema_file that takes one of the following values

'raise': raise a ValueError when registering a schema having the same $id with another schema that has already been registered

'allow': If the input schema has the same $id and version as another schema that has already been registered, it would override the existing schema. In case the input schema only has the same $id as an existing schema but a different version, the input schema would be registered along side the existing schema.

'skip': does nothing

default is set to be 'raise' which is the strictest option.

Would be useful for loading client schemas imported using importlib.resources
which are returned as file objects
Raise an error when registering a schema with the same $id and version
as another one already registered
Copy link
Member

@Zsailer Zsailer left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks, @kiendang!

open doesn't work with pathlib in 3.5
@Zsailer Zsailer merged commit 6f1933c into jupyter:master Apr 29, 2021
@kiendang kiendang deleted the name-collision branch April 29, 2021 21:52
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.

2 participants