airbyte-api-python-sdk icon indicating copy to clipboard operation
airbyte-api-python-sdk copied to clipboard

AttributeError: unable to unmarshal <response> as StreamPropertiesResponse

Open henriquemeloo opened this issue 2 years ago • 3 comments

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>

henriquemeloo avatar Dec 05 '23 13:12 henriquemeloo

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.

GKTheOne avatar Jan 30 '24 01:01 GKTheOne

I got this myself too, like what @GKTheOne is saying

dmtri35 avatar Feb 05 '24 16:02 dmtri35

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)

AliHarake avatar Feb 14 '24 10:02 AliHarake