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

UnknownType errors encountered during validation look a bit ugly #373

Closed
Julian opened this issue Nov 22, 2017 · 1 comment
Closed

UnknownType errors encountered during validation look a bit ugly #373

Julian opened this issue Nov 22, 2017 · 1 comment
Labels
Bug Something doesn't work the way it should.

Comments

@Julian
Copy link
Member

Julian commented Nov 22, 2017

⊙  ~[jsonschema:python] -c 'from jsonschema import Draft4Validator; Draft4Validator({"type": "flooglekins"}).validate("foo")'                                                                                                                                                                                                                                   Julian@home
Traceback (most recent call last):
  File "<module>", line 1, in <module>
  File "jsonschema/validators.py", line 134, in validate
    for error in self.iter_errors(*args, **kwargs):
  File "jsonschema/validators.py", line 110, in iter_errors
    for error in errors:
  File "jsonschema/_validators.py", line 290, in type_draft4
    if not any(validator.is_type(instance, type) for type in types):
  File "jsonschema/_validators.py", line 290, in <genexpr>
    if not any(validator.is_type(instance, type) for type in types):
  File "jsonschema/validators.py", line 139, in is_type
    raise UnknownType(type, instance, self.schema)
UnknownType:
Unknown type 'flooglekins' for validator with schema:
    {'type': 'flooglekins'}

While checking instance:
    'foo'

(This schema is invalid, but would like to clean up the empty extra line there).

@Julian Julian added the Bug Something doesn't work the way it should. label Aug 13, 2018
Julian added a commit that referenced this issue Jun 9, 2020
817b724 add perl implementation and test suite to the user list
ca14e01 Merge branch 'pull/382'
3dabf55 move non-format tests out of the format directory, while keeping all ECMA regex tests together
4121aa5 move format tests to their own directory
4bae8aa Add more idn-hostname tests to draft-2019-09 and draft-07
6d91158 [325] Add some more hostname tests
e593057 Merge pull request #389 from ssilverman/readme-drafts
fb3766d README: Improve issue/PR links
79bef22 README: Update language around drafts
ade47e4 README: Add Snow to the list of supporting Java validators
fc0c14e README: Update simple JSON example
1167669 README: Update structure, consistency, spacing, and wrapping
9514122 Merge pull request #388 from json-schema-org/ether/maxProperties=0
7646490 test that maxProperties = 0 means the object is empty
c3f4319 Merge pull request #384 from ChALkeR/chalker/unique
7766f48 Improve uniqueItems validation
7555d41 Add unnormalized $id tests
11f70eb [300] Add tests for valid use of empty fragments in "$id"
b106ff0 [299] Add tests for invalid use of fragments in "$id"
4a74d45 Fix "tilde" spelling
3eca41b Merge pull request #379 from json-schema-org/ether/remove-wrapped-refs
d61bae8 remove wrapped refs
536ec07 [359] Add unevaluatedProperties/unevaluatedItems cousin tests
ac63eb7 Small README update that introduces the concept of directories
697944e Merge pull request #374 from karenetheridge/ether/allOf-anyOf-oneOf
33f8549 test all the *Of keywords together
44b99ed Merge pull request #373 from karenetheridge/ether/items-and-contains
4a2b52f some tests of items + contains
7f00cc8 add test that was present for other drafts but not 2019-09
a3f9e2e Merge pull request #371 from karenetheridge/ether/if-then-else-boolean
aeeaecc some tests with if/then/else and boolean schemas
b8a083c Merge pull request #372 from nomnoms12/unique-false-and-zero
85728f1 Add tests for uniqueness [1] and [true]
fd01a60 Add tests for uniqueness [1] and [true]
0a8823c Merge pull request #370 from karenetheridge/ether/nul-char
fa6f4dd add tests for the NUL character in strings
8bf2f7f Merge pull request #369 from ssilverman/data-desc
2ba7a76 Add data description
4f66078 Merge pull request #367 from karenetheridge/ether/additionalItems
283da7c some more tests for additionalItems
7ba95f3 add tests for keywords maxContains, minContains
2f2e7cf Merge pull request #365 from karenetheridge/ether/move-ecma-regex
8388f27 move ECMA regex tests under format/

git-subtree-dir: json
git-subtree-split: 817b724b7a64d7c18a8232aa32b5f1cc1d6dd153
@Julian
Copy link
Member Author

Julian commented Jul 28, 2022

This looks better now:

⊙  ~[jsonschema:python] -c 'from jsonschema import Draft4Validator; Draft4Validator({"type": "flooglekins"}).validate("foo")'                                                       julian@Airm
Traceback (most recent call last):
  File "/Users/julian/Development/jsonschema/jsonschema/validators.py", line 273, in is_type
    return self.TYPE_CHECKER.is_type(instance, type)
  File "/Users/julian/Development/jsonschema/jsonschema/_types.py", line 120, in is_type
    raise UndefinedTypeCheck(type) from None
jsonschema.exceptions.UndefinedTypeCheck: Type 'flooglekins' is unknown to this type checker

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/julian/Development/jsonschema/jsonschema/validators.py", line 268, in validate
    for error in self.iter_errors(*args, **kwargs):
  File "/Users/julian/Development/jsonschema/jsonschema/validators.py", line 243, in iter_errors
    for error in errors:
  File "/Users/julian/Development/jsonschema/jsonschema/_validators.py", line 321, in type
    if not any(validator.is_type(instance, type) for type in types):
  File "/Users/julian/Development/jsonschema/jsonschema/_validators.py", line 321, in <genexpr>
    if not any(validator.is_type(instance, type) for type in types):
  File "/Users/julian/Development/jsonschema/jsonschema/validators.py", line 275, in is_type
    raise exceptions.UnknownType(type, instance, self.schema)
jsonschema.exceptions.UnknownType: Unknown type 'flooglekins' for validator with schema:
    {'type': 'flooglekins'}

While checking instance:
    'foo'

@Julian Julian closed this as completed Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something doesn't work the way it should.
Projects
None yet
Development

No branches or pull requests

1 participant