scaleway-sdk-python icon indicating copy to clipboard operation
scaleway-sdk-python copied to clipboard

list_images: `sbs_snapshot` volume unmarshalling error

Open Timost opened this issue 9 months ago • 1 comments

Hi,

First of all thank you for the sdk. 🙏

This is issue is very similar to: https://github.com/scaleway/scaleway-sdk-python/issues/636

It would seem that when the extra_volume is of type sbs_snapshots some data is missing from the API response.

This is the API response I get

{'arch': 'x86_64',
 'creation_date': '<redacted>'
 'default_bootscript': None,
 'extra_volumes': {'1': {'id': '<redacted>',
                         'name': '',
                         'size': 0,
                         'volume_type': 'sbs_snapshot'}},
 'from_server': '<redacted>',
 'id': '<redacted>',
 'modification_date': '<redacted>',
 'name': '<redacted>',
 'organization': '<redacted>',
 'project': '<redacted>',
 'public': False,
 'root_volume': {'id': '<redacted>',
                 'name': '<redacted>',
                 'size': 20000000000,
                 'volume_type': 'l_ssd'},
 'state': 'available',
 'tags': [],
 'zone': 'fr-par-1'}

It seems the Python code at https://github.com/scaleway/scaleway-sdk-python/blob/main/scaleway/scaleway/instance/v1/marshalling.py#L263 is expecting tags, project etc. for the extra_volumes field which are missing from the response.

The results is the following Exception:

lib/python3.11/site-packages/scaleway/instance/v1/marshalling.py", line 335, in unmarshal_Volume
    return Volume(**args)
           ^^^^^^^^^^^^^^
TypeError: Volume.__init__() missing 5 required positional arguments: 'organization', 'project', 'tags', 'state', and 'zone'

Maybe unmarshal_VolumeSummary should be used instead when the extra volume is of type sbs_snapshot ?

Could you please take a look ? This is preventing me from managing my backups properly. Thank you 🙏

Timost avatar Mar 24 '25 08:03 Timost

For now, I'm monkey patching the unmarshal_Image method with a custom one that uses unmarshal_VolumeSummary for sbs_snapshot volumes

Timost avatar Mar 24 '25 10:03 Timost