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

Required flag silently not honored when including a partial schema. #141

Closed
mschaef-da opened this issue Oct 1, 2018 · 7 comments
Closed

Comments

@mschaef-da
Copy link

This YAML:

  x: 3

Gives this result:

~$ pykwalify -d subschema-required-data.yaml -s subschema-required-schema.yaml 
 INFO - validation.valid

When validated against this schema:

schema;coordinate_value:
  type: number
  
mapping:
  point:
    mapping:
      x:
        required: true
        include: coordinate_value
      y:
        required: true
        include: coordinate_value

It looks like #85 was work on a similar scenario, but it seems like either the required flag at the include site should be ignored, or a warning/error should be issued signaling that this is not a valid schema definition.

@Grokzen
Copy link
Owner

Grokzen commented Oct 4, 2018

@mschaef-da What version are you running? The specified YAML data blob fails validation on my end

(pykwalify) ➜  pykwalify git:(master) ✗ cat a.yml; echo "------"; cat b.yml; echo "--------"; pykwalify -d a.yml -s b.yml
x: 3

------
schema;coordinate_value:
  type: number

mapping:
  point:
    mapping:
      x:
        required: true
        include: coordinate_value
      y:
        required: true
        include: coordinate_value

--------
 ERROR - validation.invalid
 ERROR -  --- All found errors ---
 ERROR - [u"Key 'x' was not defined. Path: ''"]
Traceback (most recent call last):
  File "/home/grok/.virtualenvs/pykwalify/bin/pykwalify", line 11, in <module>
    load_entry_point('pykwalify', 'console_scripts', 'pykwalify')()
  File "/home/grok/code/pykwalify/pykwalify/cli.py", line 95, in cli_entrypoint
    run(parse_cli())
  File "/home/grok/code/pykwalify/pykwalify/cli.py", line 82, in run
    c.validate()
  File "/home/grok/code/pykwalify/pykwalify/core.py", line 167, in validate
    error_msg=u'.\n - '.join(self.validation_errors)))
pykwalify.errors.SchemaError: <SchemaError: error code 2: Schema validation failed:
 - Key 'x' was not defined. Path: ''.: Path: '/'>

Tested with latest git commit.

@mschaef-da
Copy link
Author

mschaef-da commented Oct 4, 2018

$ pykwalify --version
1.6.0

@Grokzen
Copy link
Owner

Grokzen commented Oct 4, 2018

Did you not include the entire datablob that would match against that specified schema?

@mschaef-da
Copy link
Author

Argh... apologies for the mistake. The data file should read like this:

point:
  x: 3

I've since also tested against 1.7.0:

$ pykwalify -d subschema-required-data.yaml -s subschema-required-schema.yaml
 INFO - validation.valid
$ pykwalify --version
1.7.0

@Grokzen
Copy link
Owner

Grokzen commented Oct 17, 2018

Ye, i start to think that i need to rewrite the rule engine to sort this out, the lazy loading way that i am currently doing is causing more issues then what it is worth. I guess i have to fix the issues with infinite recursion problem some other way and then most of these kinds of issues would be sorted out itself.

@Grokzen
Copy link
Owner

Grokzen commented Oct 31, 2018

@mschaef-da Could you try the new branch i made in #143 to see if this solves your issue from your end? It looks promising with the rebuilded include feature, but i need more tests from real-world to verify that it works as i want.

@Grokzen
Copy link
Owner

Grokzen commented Nov 10, 2018

@mschaef-da Issue resolved inside branch feature/rebuild-include Closing this as fixed for now.

@Grokzen Grokzen closed this as completed Nov 10, 2018
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

No branches or pull requests

2 participants