airbyte-api-python-sdk
airbyte-api-python-sdk copied to clipboard
AttributeError: unable to unmarshal <response> as StreamPropertiesResponse
Making the following request
airbyte.Airbyte(server_url=server_url).streams.get_stream_properties(
airbyte.models.operations.GetStreamPropertiesRequest(
destination_id, source_id))
raises
AttributeError: unable to unmarshal <response> as typing.Optional[airbyte.models.shared.streampropertiesresponse.StreamPropertiesResponse
while running
curl '{apiUrl}/streams?sourceId={sourceId}&destinationId={destinationId}' --header 'accept: application/json'
successfully returns the same <response>
Just hit this myself.
I'm using Airbyte OSS version 0.50.40 and airbyte-api versions 0.44.2 0.44.3, and it looks like the get_stream_properties API endpoint is returning a list of StreamProperties instead of the StreamPropertiesResponse expected by the airbyte-api library.
I got this myself too, like what @GKTheOne is saying
I got the same error as you guys and fixed the issue in the airbyte/utils/utils.py by modifying the unmarshal_json function to accept a list and it worked
def unmarshal_json(data, typ, decoder=None):
unmarshal = make_dataclass('Unmarshal', [('res', List[typ] if isinstance(json.loads(data), list) else typ)],
bases=(DataClassJsonMixin,))
json_dict = json.loads(data)
try:
out = unmarshal.from_dict({"res": json_dict})
except AttributeError as attr_err:
raise AttributeError(
f'unable to unmarshal {data} as {typ} - {attr_err}') from attr_err
return out.res if decoder is None else decoder(out.res)