-
-
Notifications
You must be signed in to change notification settings - Fork 94
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
patternProperties interferes with properties #183
Comments
I'm happy to take a crack at a PR, but I'm a complete Rust novice, so it might be a little ugly at first... |
In the process of trying to debug this with different schema combinations I also uncovered a case where trying to compile a valid schema leads to a Here is the schema: {
"type": "object",
"properties": {
"eo:cloud_cover": {
"type": "number"
}
},
"patternProperties": {
"^(?!eo:)": {}
}
} |
Hi @duckontheweb ! Thank you for an awesome bug report :) I'd be happy to review a PR, sure. Otherwise, I think that I'll have some time over the weekend to check why the bug is happening |
The However, it seems like this is also the cause of the original issue. If I change the It seems like the real bug is that compilation should have returned an error in the original example. |
One possible solution to this would be to use |
I looked into this a bit more, and it's far from trivial to swap these out. Many of the |
@Stranger6667 It looks like the reason that this compiles successfully even though it contains an unsupported look-behind assertion is with the logic introduced in #173. If However, the following example is a valid case where {
"type": "object",
"properties": {
"eo:cloud_cover": {
"type": "number",
},
},
"patternProperties": {
"^(?!eo:)": {}
},
"additionalProperties": false
} This pattern is used throughout the STAC extension schemas to basically say "allow additional properties as long as they don't start with this prefix". Let me know if you want me to open a separate issue for this so that it's not buried in this one. |
Thank you for pinging me :) I will take a deeper look tomorrow |
Oh, it is definitely a bug. With the current regex library, it should fail to compile indeed. I will create a new issue & dig why it is happening. That pattern should be compiled in those "combined" validators. |
Probably, in the |
The |
The |
The |
At first glance, I expect that there should be not much hassle with replacing However, if I missed anything there, I believe that those things should not be hard to solve. |
Actually, it looks like the biggest challenge is going to be the lack of replace methods. There is a suggested workaround here, so I'll give that a go. |
Released in |
It seems like the presence of
"patternProperties"
interferes with validation that should happen in"properties"
.This replit shows an example of an instance that should fail validation (and does fail in jsonschemavalidator.net). If you comment out the
"patternProperties"
portion of the schema, it fails as expected.I don't have a good enough understanding of the
jsonschema
internals, but it seems like this could be related to changes from #173 .UPDATE: I updated the replit and the jsonschemavalidator link to provide a more minimal example.
The text was updated successfully, but these errors were encountered: