surrealdb/surrealdb.py

Unable to reproduce examples due to typo in http client

TudorAndrei opened this issue · 1 comments

When running the examples I get the following error:

Traceback (most recent call last):
  File "/home/main.py", line 89, in <module>
    asyncio.run(run_all())
  File "/usr/lib/python3.8/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/home/main.py", line 79, in run_all
    await create_all()
  File "/home/main.py", line 11, in create_all
    response = await client.create_all(table, data)
  File "/home/.venv/lib/python3.8/site-packages/surrealdb/clients/http.py", line 168, in create_all
    response = await self._request(
  File "/home/.venv/lib/python3.8/site-packages/surrealdb/clients/http.py", line 117, in _request
    surreal_data = surreal_json[0]
KeyError: 0

I have create a PR #26 to solve this issue. Not only that, it's also not handled as a authentication error. This is the content of surreal_json:

{'code': 403, 'details': 'Authentication failed', 'description': 'Your authentication details are invalid. Reauthenticate using valid authentication parameters.', 'information': 'There was a problem with authentication'}

This is fixed by PR #26