Comments (8)
Thanks @FrederikP, you found the bug. :-) The same problem was on more places. It's fixed in master. I plan to do more stuff tomorrow, do you want to release it today or can you wait till tomorrow, @j616?
from python-fastjsonschema.
Doing some more digging with this. Turned out I was still on 1.6. Now on 2.3. The test case above no longer fails for me but I'm still getting the same sort of error on slightly more complex cases. I'll try and put together a new test case.
from python-fastjsonschema.
I don't have much more useful info yet, but it does seem that the problem is non-deterministic. Running the same time multiple times results in different key errors (in the example above, they would be with keys at the baz/bit level) or occasionally results in the document validating successfully...
from python-fastjsonschema.
Any chance someone could take a look at this?
from python-fastjsonschema.
Just discovered a bug related to this by using your example schema and data and debugging into the generated code (using compile_to_code). The key error is reproducable for me.
There is an issue with variables being overwritten, because in python the scopes of variables are not very strict. I'm not very familiar with the code, but maybe I can find a way to fix this.
The issue seems to be with self.l('for key, val in {variable}.items():'):
from generate_pattern_properties. When these statements are nested, key and val get overwritten in certain circumstances. In your example this leads to val being assigned an empty object in the deeper object and then when it wants to check for bit, it uses this empty object instead of the correct one that was assigned earlier.
Also looking at the way this is built, I'm not sure that similiar issues can not be forced when it comes to nested properties with the same property names. Fully classifying all variables based on the properties would fix this.
e.g. data.item.foo.bar_value, data.item.foo.bar_key
from python-fastjsonschema.
I plan to look at it tomorrow.
from python-fastjsonschema.
Okay, my first naive idea was to use something like:
{name}_key, {name}_val
but the name template variable seems to be only made for use in strings and not in the code as it can depend on one more formatting step.
I'll let you look into it @horejsek . If you have any questions about what I found out, let me know. When debugging the generated code using the example from this issue, the problem becomes clear quite quickly.
from python-fastjsonschema.
I can wait until tomorrow. For now it's useful to know I don't have to find a work around and to know I'm not doing anything silly on my end! Thanks.
from python-fastjsonschema.
Related Issues (20)
- Is there a way to support multiple errors instead of showing just the first error in the schema? HOT 1
- Please make a new release HOT 1
- Uniqueness enforced if uniqueItems explicitly set to False HOT 1
- 2.16.1: test_compile_to_code_custom_format fails HOT 3
- 2.16.2 not available on pypi.org HOT 1
- RFC 3339 date month and mday should be two digit HOT 2
- Getting UnboundLocalError HOT 3
- are the compiled validation functions cached? HOT 2
- Datadog's Guarddog detects exec in setup.py and complains HOT 4
- Python 3.10 venv build is failing HOT 1
- sdist is missing tests HOT 1
- Cannot parse int64 types HOT 1
- [Potential bug] not working validation for properties not defined in the schema object HOT 1
- Release request HOT 1
- Wrong tag name for 2.17.0 HOT 1
- 2.17.0 sdist contains "stray" tests/examples/lengths that breaks tests HOT 2
- errors for missing required properties
- Error occurs when fastjsonschema generates empty except block HOT 2
- Feature request: automatically add nested defaults HOT 7
- RFE: is it possible to start making github releases?🤔 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-fastjsonschema.