Skip to content

Bug: User model #239

@Eggwise

Description

@Eggwise

when trying to list the users in my instance (see following code)

syncano.connect(api_key=API_KEY)
users = User.please.list(instance_name=INSTANCE)
for user in users:
    # print(user)
    print(user.user_key)

I get the following error:

Traceback (most recent call last):
File "_**syncano_backend/test/test.py", line 34, in
for user in users:
File "/usr/local/lib/python3.5/dist-packages/syncano/models/manager.py", line 812, in iterator
yield self.serialize(o)
File "/usr/local/lib/python3.5/dist-packages/syncano/models/manager.py", line 741, in serialize
return model(__properties) if self._serialize else data
File "/usr/local/lib/python3.5/dist-packages/syncano/models/archetypes.py", line 90, in init
self.to_python(kwargs)
File "/usr/local/lib/python3.5/dist-packages/syncano/models/archetypes.py", line 247, in to_python
setattr(self, field.name, value)
File "/usr/local/lib/python3.5/dist-packages/syncano/models/fields.py", line 105, in set
instance.raw_data[self.name] = self.to_python(value)
File "/usr/local/lib/python3.5/dist-packages/syncano/models/fields.py", line 524, in to_python
return self.rel(
*value)
File "/usr/local/lib/python3.5/dist-packages/syncano/models/classes.py", line 145, in new
raise SyncanoValidationError('Field "instance_name" is required.')
syncano.exceptions.SyncanoValidationError: Field "instance_name" is required.

I tested my api key in http://docs.syncano.io/v0.1.1/docs/users-list and it worked. It looks like the python lib cant create a user model object from the response.

Code from the stacktrace


   def serialize(self, data, model=None):
        """Serializes passed data to related :class:`~syncano.models.base.Model` class."""
        model = model or self.model
        if data == '':
            return

        if isinstance(data, model):
            return data

        if not isinstance(data, dict):
            raise SyncanoValueError('Unsupported data type.')

        properties = deepcopy(self.properties)
        properties.update(data)
        return model(**properties) if self._serialize else data`


Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions