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

getschema.fix_type function: A valid null object is rejected #17

Open
daigotanaka opened this issue Jul 12, 2021 · 0 comments
Open

getschema.fix_type function: A valid null object is rejected #17

daigotanaka opened this issue Jul 12, 2021 · 0 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@daigotanaka
Copy link
Contributor

daigotanaka commented Jul 12, 2021

v0.2.6

fix_type A null object (=dictionary) is not handled correctly. It results in

This test:

import getschema

null_entries = {
    "index": None,
    "array": [
        "1.5",
        None,
    ],
    "nested_field": None,
    "boolean_field": None,
    "number_field": None,
    "string_field": None,
}

def test_reject_null_object():
    schema = getschema.infer_schema(records)
    # This will pass
    _ = getschema.fix_type(null_entries, schema)

    schema["properties"]["nested_field"]["type"] = ["object"]
    try:
        _ = getschema.fix_type(null_entries, schema)
    except Exception as e:
        assert(str(e).startswith("Null object given at"))
    else:
        raise Exception("Supposed to fail with null value")

...will fail with:

KeyError: "property type (object) Expected a dict object.Got: <class 'NoneType'>...
@daigotanaka daigotanaka self-assigned this Jul 12, 2021
@daigotanaka daigotanaka added the bug Something isn't working label Jul 12, 2021
@daigotanaka daigotanaka modified the milestones: v0.2.6, v0.2.7 Jul 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant