OpenVoiceOS / ovos-personal-backend

personal backend - self-hosted backend to manage multiple OVOS devices
Apache License 2.0
78 stars 26 forks source link

fix/database issues #55

Closed JarbasAl closed 1 year ago

JarbasAl commented 1 year ago

some of the new CRUD endpoints have a few bugs

test with backend-client https://github.com/OpenVoiceOS/ovos-backend-client/pull/30


    db = DatabaseApi("666", backend_type=BackendType.PERSONAL)
    print(db.list_devices())
    print(db.delete_device("123"))
    print(db.add_device("123", "testtoken"))
    print(db.list_devices())
    print(db.get_device("123"))
    print(db.list_devices())
    print(db.update_device("123", name="bad device"))
    print(db.get_device("123"))
    print(db.delete_device("123"))
    print(db.list_devices())
``
emphasize commented 1 year ago

Getting back on https://github.com/OpenVoiceOS/ovos-personal-backend/pull/51#discussion_r1155328920

theoretically this is correct, but practically it doesn't pull Flask-MySQLdb (tested in a docker scenario)

WARNING: ovos-local-backend 0.2.0a5 does not provide the extra 'mysql'

EDIT: Got the problem. We have to use extras_require instead of extras_requires here

emphasize commented 1 year ago

problems with a keyword (also meta -> metadata_json) https://github.com/OpenVoiceOS/ovos-personal-backend/blob/f4909e7b37a7959e67fe7627700ae9a45663f316/ovos_local_backend/database.py#L313-L318

[2023-04-08 14:42:19,999] ERROR in app: Exception on /v1/device/b1c9a688-c92c-495d-bea3-699a15f15225/skill [PUT]
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 2528, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 1825, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 1823, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 1799, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/usr/local/lib/python3.10/dist-packages/ovos_local_backend/backend/decorators.py", line 56, in decorated
    return f(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/ovos_local_backend/backend/device.py", line 57, in skill_settings
    s = SkillSettings.deserialize(flask.request.json)
  File "/usr/local/lib/python3.10/dist-packages/ovos_local_backend/database.py", line 394, in deserialize
    return update_skill_settings(remote_id,
  File "/usr/local/lib/python3.10/dist-packages/ovos_local_backend/database.py", line 746, in update_skill_settings
    settings = add_skill_settings(remote_id=remote_id,
  File "/usr/local/lib/python3.10/dist-packages/ovos_local_backend/database.py", line 700, in add_skill_settings
    entry = SkillSettings(remote_id=remote_id,
  File "<string>", line 4, in __init__
  File "/usr/local/lib/python3.10/dist-packages/sqlalchemy/orm/state.py", line 575, in _initialize_instance
    with util.safe_reraise():
  File "/usr/local/lib/python3.10/dist-packages/sqlalchemy/util/langhelpers.py", line 147, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/usr/local/lib/python3.10/dist-packages/sqlalchemy/orm/state.py", line 573, in _initialize_instance
    manager.original_init(*mixed[1:], **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/sqlalchemy/orm/decl_base.py", line 2139, in _declarative_constructor
    raise TypeError(
TypeError: 'settings_json' is an invalid keyword argument for SkillSettings

BTW the default has to be a dict, not a str

JarbasAl commented 1 year ago

@|ovos-skills-info.openvoiceos

besides above issue it writes a remote_id entry (SkillSettings) without uuid EDIT: _(seen that this is a result of isolated_skills = False, but looking at _

https://github.com/OpenVoiceOS/ovos-personal-backend/blob/5029f4bd5a97fafd47590ca35757f579e64f53d4/ovos_local_backend/backend/crud.py#L36-L39 this shouldn't have @|)

(endpoint /v1/device/uuid/skill (device.py) - SkillSettingsApi().upload_skill_settings())

i think core might be sending it that way already as it was expected by selene....

emphasize commented 1 year ago

Yeah, saw that. That's why i deleted the comment