question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Schema file not working anymore with Cerberus 1.3

See original GitHub issue

Used Cerberus version / latest commit: Cerberus 1.3 / Python 3.5.2

  • I have the capacity to improve the docs when my problem is solved.

  • I have the capacity to submit a patch when a bug is identified.

  • My question does not concern a practical use-case that I can’t figure out to solve.


Use-case abstract

Since Cerberus 1.3, keyschema and valueschema are deprecated and should still work, but I get an error when using them.

The error is gone when using the new keys keysrules and valuesrules.

Here is my schema :

requests:
  type: dict
  keyschema:
    type: string
  valueschema:
    type: dict
    schema:
      aggs:
        type: dict
        keyschema:
          type: string
        valueschema:
          type: dict

My Python code :

#!/usr/bin/env python3

from yaml import load, load_all
from cerberus import Validator

schemafile = "schema.yml"

with open(schemafile, "r") as f:
    schema = load(f)

v = Validator(schema)

And the Python error :


Traceback (most recent call last):
  File "./test.py", line 11, in <module>
    v = Validator(schema)
  File "/usr/local/lib/python3.5/dist-packages/cerberus/validator.py", line 181, in __init__
    self.schema = kwargs.get('schema', None)
  File "/usr/local/lib/python3.5/dist-packages/cerberus/validator.py", line 562, in schema
    self._schema = DefinitionSchema(self, schema)
  File "/usr/local/lib/python3.5/dist-packages/cerberus/schema.py", line 76, in __init__
    self.validate(schema)
  File "/usr/local/lib/python3.5/dist-packages/cerberus/schema.py", line 247, in validate
    self._validate(schema)
  File "/usr/local/lib/python3.5/dist-packages/cerberus/schema.py", line 263, in _validate
    raise SchemaError(self.schema_validator.errors)
cerberus.schema.SchemaError: {'requests': [{'valuesrules': [{'schema': ['no definitions validate', {'anyof definition 0': [{'aggs': [{'valueschema': ['unknown rule'], 'keyschema': ['unknown rule']}]}], 'anyof definition 1': [{'aggs': ['unknown rule']}]}]}]}]}

Bug report / Feature request

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
nicolaiaroccicommented, May 10, 2019

howdy everyone, v1.3.1 has been released a few minutes ago.

1reaction
funkyfuturecommented, May 10, 2019

yes, thanks for your feedback.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python Cerberus: problem with validation different schemas ...
It seems that anyof_schema rule works only if all schemas in the provided set describe the same data type (e.g. dictionaries). Why anyof_schema ......
Read more >
Cerberus Changelog
Cerberus is a collaboratively funded project, see the funding page. ... (Frank Sachsenheim); Fix: Schema registries do not work on dict fields. Closes...
Read more >
Do Not Use If-Else For Validating Data Objects In Python ...
Several weeks ago, I introduced a Python library called Cerberus. It can enable us to write a “schema” to validate our data objects ......
Read more >
Cerberus Documentation - Read the Docs
Validation schemas themselves are validated when passed to the validator or a new set of rules is set for a document's field. A...
Read more >
How to reset the Python tool - Alteryx Community
As the wheel files are no longer included with the installed ... /wheels/Cerberus-1.3.1.tar.gz Skipping link: wrong project name (not ayx): ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found