dataops-tk / tap-powerbi-metadata

tap-powerbi-metadata
MIT License
5 stars 2 forks source link

Use of ComplexType results in "TypeError: 'bool' object is not iterable" #9

Closed jtimeus-slalom closed 3 years ago

jtimeus-slalom commented 3 years ago

Whenever I use the ComplexType and then pipe the activity to target-csv I get a TypeError: 'bool' object is not iterable error

Traceback (most recent call last):
  File "c:\python38\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\python38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\john.timeus\.local\bin\target-csv.exe\__main__.py", line 7, in <module>
  File "c:\users\john.timeus\.local\pipx\venvs\target-csv\lib\site-packages\target_csv.py", line 141, in main
    state = persist_messages(config.get('delimiter', ','),
  File "c:\users\john.timeus\.local\pipx\venvs\target-csv\lib\site-packages\target_csv.py", line 59, in persist_messages
    validators[o['stream']].validate(o['record'])
  File "c:\users\john.timeus\.local\pipx\venvs\target-csv\lib\site-packages\jsonschema\validators.py", line 129, in validate
    for error in self.iter_errors(*args, **kwargs):
  File "c:\users\john.timeus\.local\pipx\venvs\target-csv\lib\site-packages\jsonschema\validators.py", line 105, in iter_errors
    for error in errors:
  File "c:\users\john.timeus\.local\pipx\venvs\target-csv\lib\site-packages\jsonschema\_validators.py", line 300, in properties_draft4
    for error in validator.descend(
  File "c:\users\john.timeus\.local\pipx\venvs\target-csv\lib\site-packages\jsonschema\validators.py", line 121, in descend
    for error in self.iter_errors(instance, schema):
  File "c:\users\john.timeus\.local\pipx\venvs\target-csv\lib\site-packages\jsonschema\validators.py", line 105, in iter_errors
    for error in errors:
  File "c:\users\john.timeus\.local\pipx\venvs\target-csv\lib\site-packages\jsonschema\_validators.py", line 312, in required_draft4
    for property in required:
TypeError: 'bool' object is not iterableTraceback (most recent call last):
  File "c:\python38\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\python38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\john.timeus\.local\bin\target-csv.exe\__main__.py", line 7, in <module>
  File "c:\users\john.timeus\.local\pipx\venvs\target-csv\lib\site-packages\target_csv.py", line 141, in main
    state = persist_messages(config.get('delimiter', ','),
  File "c:\users\john.timeus\.local\pipx\venvs\target-csv\lib\site-packages\target_csv.py", line 59, in persist_messages
    validators[o['stream']].validate(o['record'])
  File "c:\users\john.timeus\.local\pipx\venvs\target-csv\lib\site-packages\jsonschema\validators.py", line 129, in validate
    for error in self.iter_errors(*args, **kwargs):
  File "c:\users\john.timeus\.local\pipx\venvs\target-csv\lib\site-packages\jsonschema\validators.py", line 105, in iter_errors
    for error in errors:
  File "c:\users\john.timeus\.local\pipx\venvs\target-csv\lib\site-packages\jsonschema\_validators.py", line 300, in properties_draft4
    for error in validator.descend(
  File "c:\users\john.timeus\.local\pipx\venvs\target-csv\lib\site-packages\jsonschema\validators.py", line 121, in descend
    for error in self.iter_errors(instance, schema):
  File "c:\users\john.timeus\.local\pipx\venvs\target-csv\lib\site-packages\jsonschema\validators.py", line 105, in iter_errors
    for error in errors:
  File "c:\users\john.timeus\.local\pipx\venvs\target-csv\lib\site-packages\jsonschema\_validators.py", line 312, in required_draft4
    for property in required:
TypeError: 'bool' object is not iterable
jtimeus-slalom commented 3 years ago

Attached is a anonymized jsonl (change extension from txt to jsonl) that can be passed to target-csv to generate the error

cat .\Activity.txt | target-csv

Activity.zip

aaronsteers commented 3 years ago

Hi, John. Thanks very much. I actually found the issue quickly. The problem is there are two specs for "required" in different versions of JSON Schema. As of Draft 4 (which is what we are using and which most other versions use), the "required" property is defined at the object (complex-type) level, and it contains a list of required attributes. Specification text here: https://tools.ietf.org/html/draft-fge-json-schema-validation-00#page-12

Previously, we were also appending "required": true which was conflicting with that spec.

The latest update (poetry add singer-sdk==0.0.2-dev.1068113915) should resolve the issue, but please let me know once you've confirmed. Thanks!

Also, for reference, here's the relevant commit diff: https://gitlab.com/meltano/singer-sdk/-/commit/c7b70eb3ac5becd379f85dd662c30441f1913470 I simply removed the addl. boolean flag in favor of the list-based approached which was already implemented.

jtimeus-slalom commented 3 years ago

Confirmed fixed, thanks!