Giter VIP home page Giter VIP logo

Comments (8)

horejsek avatar horejsek commented on July 18, 2024 1

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.

j616 avatar j616 commented on July 18, 2024

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.

j616 avatar j616 commented on July 18, 2024

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.

j616 avatar j616 commented on July 18, 2024

Any chance someone could take a look at this?

from python-fastjsonschema.

FrederikP avatar FrederikP commented on July 18, 2024

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.

horejsek avatar horejsek commented on July 18, 2024

I plan to look at it tomorrow.

from python-fastjsonschema.

FrederikP avatar FrederikP commented on July 18, 2024

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.

j616 avatar j616 commented on July 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.