airbytehq / airbyte

The leading data integration platform for ETL / ELT data pipelines from APIs, databases & files to data warehouses, data lakes & data lakehouses. Both self-hosted and Cloud-hosted.
https://airbyte.com
Other
15.5k stars 3.99k forks source link

CDK + Connector Builder: Allow for record selection on response body with empty key #29660

Closed maxi297 closed 1 year ago

maxi297 commented 1 year ago

What area the feature impact?

Connectors

Revelant Information

When a user configure a record selection, we use dpath to fetch the nested object. However in the current state, dpath can raise an exception. Given a response body with empty keys, dpath does not allow for get. We can reproduce this error with a very small snippet of code:

import dpath.util
response_body = {"toto": {"tata": 1, "": 2}}
dpath.util.get(response_body, "toto", default=[])
Traceback (most recent call last):
  File "/Users/maxime/.pyenv/versions/3.9.11/lib/python3.9/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "/Users/maxime/devel/code/airbyte/airbyte-integrations/connectors/source-gnews/.venv/lib/python3.9/site-packages/dpath/util.py", line 173, in get
    results = dpath.segments.fold(obj, f, [])
  File "/Users/maxime/devel/code/airbyte/airbyte-integrations/connectors/source-gnews/.venv/lib/python3.9/site-packages/dpath/segments.py", line 347, in fold
    for pair in walk(obj):
  File "/Users/maxime/devel/code/airbyte/airbyte-integrations/connectors/source-gnews/.venv/lib/python3.9/site-packages/dpath/segments.py", line 73, in walk
    for found in walk(v, location + (k,)):
  File "/Users/maxime/devel/code/airbyte/airbyte-integrations/connectors/source-gnews/.venv/lib/python3.9/site-packages/dpath/segments.py", line 68, in walk
    raise InvalidKeyName("Empty string keys not allowed without "
dpath.exceptions.InvalidKeyName: Empty string keys not allowed without dpath.options.ALLOW_EMPTY_STRING_KEYS=True: ('toto', '')

A user should be able to use record select even if it's response body contains empty strings.

Notes:

localfolkhero commented 1 year ago

Hello - is there a path to resolution, or should I rewrite my airbyte flows with something else?

sherifnada commented 1 year ago

@localfolkero this fix will ship soon!