airbytehq / airbytehq/airbyte-api-python-sdk

Cannot perform operations with custom destination, fails to unmarshal

Đang mở
#88 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
61
Fork
27
Merge trung bình
4 phút
Pull request đã merge (30 ngày)
2

Mô tả

When the response comes back, there is no `destination_type` field, meaning that it fails to deserialize.

```
KeyError Traceback (most recent call last)
Cell In[46], line 1
----> 1 res = s.destinations.list_destinations(request=api.ListDestinationsRequest(
2 workspace_ids=[
3 workspace_id
4 ],
5 ))

File ~/envs/default/lib/python3.11/site-packages/airbyte_api/destinations.py:223, in Destinations.list_destinations(self, request)
220 if http_res.status_code == 200:
221 # pylint: disable=no-else-return
222 if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
--> 223 out = utils.unmarshal_json(http_res.text, Optional[models.DestinationsResponse])
224 res.destinations_response = out
225 else:

File ~/envs/default/lib/python3.11/site-packages/airbyte_api/utils/utils.py:825, in unmarshal_json(data, typ, decoder)
823 json_dict = json.loads(data)
824 try:
--> 825 out = unmarshal.from_dict({"res": json_dict})
826 except AttributeError as attr_err:
827 raise AttributeError(
828 f"unable to unmarshal {data} as {typ} - {attr_err}"
829 ) from attr_err

File ~/envs/default/lib/python3.11/site-packages/dataclasses_json/api.py:70, in DataClassJsonMixin.from_dict(cls, kvs, infer_missing)
65 @classmethod
66 def from_dict(cls: Type[A],
67 kvs: Json,
68 *,
69 infer_missing=False) -> A:
---> 70 return _decode_dataclass(cls, kvs, infer_missing)

File ~/envs/default/lib/python3.11/site-packages/dataclasses_json/core.py:221, in _decode_dataclass(cls, kvs, infer_missing)
219 init_kwargs[field.name] = value
220 elif _is_supported_generic(field_type) and field_type != str:
--> 221 init_kwargs[field.name] = _decode_generic(field_type,
222 field_value,
223 infer_missing)
224 else:
225 init_kwargs[field.name] = _support_extended_types(field_type,
226 field_value)

File ~/envs/default/lib/python3.11/site-packages/dataclasses_json/core.py:323, in _decode_generic(type_, value, infer_missing)
321 elif _is_optional(type_) and len(_args) == 2: # Optional
322 type_arg = _get_type_arg_param(type_, 0)
--> 323 res = _decode_type(type_arg, value, infer_missing)
324 else: # Union (already decoded or try to decode a dataclass)
325 type_options = _get_type_args(type_)

File ~/envs/default/lib/python3.11/site-packages/dataclasses_json/core.py:235, in _decode_type(type_, value, infer_missing)
233 return _get_decoder_in_global_config(type_)(value)
234 if _is_supported_generic(type_):
--> 235 return _decode_generic(type_, value, infer_missing)
236 if is_dataclass(type_) or is_dataclass(value):
237 return _decode_dataclass(type_, value, infer_missing)

File ~/envs/default/lib/python3.11/site-packages/dataclasses_json/core.py:315, in _decode_generic(type_, value, infer_missing)
313 elif _is_generic_dataclass(type_):
314 origin = _get_type_origin(type_)
--> 315 res = _decode_dataclass(origin, value, infer_missing)
316 else: # Optional or Union
317 _args = _get_type_args(type_)

File ~/envs/default/lib/python3.11/site-packages/dataclasses_json/core.py:221, in _decode_dataclass(cls, kvs, infer_missing)
219 init_kwargs[field.name] = value
220 elif _is_supported_generic(field_type) and field_type != str:
--> 221 init_kwargs[field.name] = _decode_generic(field_type,
222 field_value,
223 infer_missing)
224 else:
225 init_kwargs[field.name] = _support_extended_types(field_type,
226 field_value)

File ~/envs/default/lib/python3.11/site-packages/dataclasses_json/core.py:303, in _decode_generic(type_, value, infer_missing)
301 xs = dict(zip(_decode_items(_get_type_arg_param(type_, 0), value.keys(), infer_missing), value.values()))
302 else:
--> 303 xs = _decode_items(_get_type_arg_param(type_, 0), value, infer_missing)
305 # get the constructor if using corresponding generic type in `typing`
306 # otherwise fallback on constructing using type_ itself
307 materialize_type = type_

File ~/envs/default/lib/python3.11/site-packages/dataclasses_json/core.py:402, in _decode_items(type_args, xs, infer_missing)
397 else:
398 raise TypeError(f"Number of types specified in the collection type {str(type_args)} "
399 f"does not match number of elements in the collection. In case you are working with tuples"
400 f"take a look at this document "
401 f"docs.python.org/3/library/typing.html#annotating-tuples.")
--> 402 return list(_decode_type(type_args, x, infer_missing) for x in xs)

File ~/envs/default/lib/python3.11/site-packages/dataclasses_json/core.py:402, in (.0)
397 else:
398 raise TypeError(f"Number of types specified in the collection type {str(type_args)} "
399 f"does not match number of elements in the collection. In case you are working with tuples"
400 f"take a look at this document "
401 f"docs.python.org/3/library/typing.html#annotating-tuples.")
--> 402 return list(_decode_type(type_args, x, infer_missing) for x in xs)

File ~/envs/default/lib/python3.11/site-packages/dataclasses_json/core.py:235, in _decode_type(type_, value, infer_missing)
233 return _get_decoder_in_global_config(type_)(value)
234 if _is_supported_generic(type_):
--> 235 return _decode_generic(type_, value, infer_missing)
236 if is_dataclass(type_) or is_dataclass(value):
237 return _decode_dataclass(type_, value, infer_missing)

File ~/envs/default/lib/python3.11/site-packages/dataclasses_json/core.py:315, in _decode_generic(type_, value, infer_missing)
313 elif _is_generic_dataclass(type_):
314 origin = _get_type_origin(type_)
--> 315 res = _decode_dataclass(origin, value, infer_missing)
316 else: # Optional or Union
317 _args = _get_type_args(type_)

File ~/envs/default/lib/python3.11/site-packages/dataclasses_json/core.py:173, in _decode_dataclass(cls, kvs, infer_missing)
170 if not field.init:
171 continue
--> 173 field_value = kvs[field.name]
174 field_type = types[field.name]
175 if field_value is None:

KeyError: 'destination_type'
```

These operations work fine if I just use the public api.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.