grai-io / grai-core

https://www.grai.io
Other
293 stars 20 forks source link

`'NoneType' object has no attribute 'encode'` on homepage search bar #334

Closed FlavSF closed 1 year ago

FlavSF commented 1 year ago

Hi,

Running Grai locally and after creating a few nodes/edges, I still see this error as soon as I click the search bar on the homepage.

Here are the logs:

grai-server-frontend-1            | 172.19.0.1 - - [04/May/2023:21:16:52 +0000] "GET /default/default HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36" "-"
grai-server-frontend-1            | 172.19.0.1 - - [04/May/2023:21:16:52 +0000] "GET /favicon.ico HTTP/1.1" 304 0 "http://localhost:3000/default/default" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36" "-"
grai-server-the_guide-1           | 'NoneType' object has no attribute 'encode'
grai-server-the_guide-1           |
grai-server-the_guide-1           | GraphQL request:4:5
grai-server-the_guide-1           | 3 |     id
grai-server-the_guide-1           | 4 |     search_key
grai-server-the_guide-1           |   |     ^
grai-server-the_guide-1           | 5 |     __typename
grai-server-the_guide-1           | Traceback (most recent call last):
grai-server-the_guide-1           |   File "/usr/local/lib/python3.11/site-packages/graphql/execution/execute.py", line 528, in await_result
grai-server-the_guide-1           |     return_type, field_nodes, info, path, await result
grai-server-the_guide-1           |                                           ^^^^^^^^^^^^
grai-server-the_guide-1           |   File "/usr/local/lib/python3.11/site-packages/strawberry_django_plus/utils/aio.py", line 89, in resolve_async
grai-server-the_guide-1           |     ret = resolver(await value)
grai-server-the_guide-1           |                    ^^^^^^^^^^^
grai-server-the_guide-1           |   File "/usr/local/lib/python3.11/site-packages/asgiref/sync.py", line 448, in __call__
grai-server-the_guide-1           |     ret = await asyncio.wait_for(future, timeout=None)
grai-server-the_guide-1           |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
grai-server-the_guide-1           |   File "/usr/local/lib/python3.11/asyncio/tasks.py", line 442, in wait_for
grai-server-the_guide-1           |     return await fut
grai-server-the_guide-1           |            ^^^^^^^^^
grai-server-the_guide-1           |   File "/usr/local/lib/python3.11/site-packages/asgiref/current_thread_executor.py", line 22, in run
grai-server-the_guide-1           |     result = self.fn(*self.args, **self.kwargs)
grai-server-the_guide-1           |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
grai-server-the_guide-1           |   File "/usr/local/lib/python3.11/site-packages/asgiref/sync.py", line 490, in thread_handler
grai-server-the_guide-1           |     return func(*args, **kwargs)
grai-server-the_guide-1           |            ^^^^^^^^^^^^^^^^^^^^^
grai-server-the_guide-1           |   File "/usr/local/lib/python3.11/site-packages/strawberry/types/fields/resolver.py", line 187, in __call__
grai-server-the_guide-1           |     return self.wrapped_func(*args, **kwargs)
grai-server-the_guide-1           |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
grai-server-the_guide-1           |   File "/usr/src/app/api/types.py", line 580, in search_key
grai-server-the_guide-1           |     return client.generate_secured_api_key(
grai-server-the_guide-1           |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
grai-server-the_guide-1           |   File "/usr/src/app/api/search.py", line 6, in generate_secured_api_key
grai-server-the_guide-1           |     return SearchClient.generate_secured_api_key(parent_api_key, restrictions)
grai-server-the_guide-1           |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
grai-server-the_guide-1           |   File "/usr/local/lib/python3.11/site-packages/algoliasearch/search_client.py", line 275, in generate_secured_api_key
grai-server-the_guide-1           |     parent_api_key.encode("utf-8"),
grai-server-the_guide-1           |     ^^^^^^^^^^^^^^^^^^^^^
grai-server-the_guide-1           | AttributeError: 'NoneType' object has no attribute 'encode'
grai-server-the_guide-1           | Stack (most recent call last):
grai-server-the_guide-1           |   File "/usr/local/lib/python3.11/threading.py", line 995, in _bootstrap
grai-server-the_guide-1           |     self._bootstrap_inner()
grai-server-the_guide-1           |   File "/usr/local/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
grai-server-the_guide-1           |     self.run()
grai-server-the_guide-1           |   File "/usr/local/lib/python3.11/threading.py", line 975, in run
grai-server-the_guide-1           |     self._target(*self._args, **self._kwargs)
grai-server-the_guide-1           |   File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 83, in _worker
grai-server-the_guide-1           |     work_item.run()
grai-server-the_guide-1           |   File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
grai-server-the_guide-1           |     result = self.fn(*self.args, **self.kwargs)
grai-server-the_guide-1           |   File "/usr/local/lib/python3.11/site-packages/asgiref/sync.py", line 248, in _run_event_loop
grai-server-the_guide-1           |     loop.run_until_complete(coro)
grai-server-the_guide-1           |   File "/usr/local/lib/python3.11/asyncio/base_events.py", line 640, in run_until_complete
grai-server-the_guide-1           |     self.run_forever()
grai-server-the_guide-1           |   File "/usr/local/lib/python3.11/asyncio/base_events.py", line 607, in run_forever
grai-server-the_guide-1           |     self._run_once()
grai-server-the_guide-1           |   File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1922, in _run_once
grai-server-the_guide-1           |     handle._run()
grai-server-the_guide-1           |   File "/usr/local/lib/python3.11/asyncio/events.py", line 80, in _run
grai-server-the_guide-1           |     self._context.run(self._callback, *self._args)
grai-server-the_guide-1           |   File "/usr/local/lib/python3.11/site-packages/asgiref/sync.py", line 306, in main_wrap
grai-server-the_guide-1           |     result = await self.awaitable(*args, **kwargs)
grai-server-the_guide-1           |   File "/usr/local/lib/python3.11/site-packages/strawberry/django/views.py", line 254, in dispatch
grai-server-the_guide-1           |     return await self.run(request=request)
grai-server-the_guide-1           |   File "/usr/local/lib/python3.11/site-packages/strawberry/http/async_base_view.py", line 176, in run
grai-server-the_guide-1           |     result = await self.execute_operation(
grai-server-the_guide-1           |   File "/usr/local/lib/python3.11/site-packages/strawberry/http/async_base_view.py", line 115, in execute_operation
grai-server-the_guide-1           |     return await self.schema.execute(
grai-server-the_guide-1           |   File "/usr/local/lib/python3.11/site-packages/strawberry/schema/schema.py", line 248, in execute
grai-server-the_guide-1           |     result = await execute(
grai-server-the_guide-1           |   File "/usr/local/lib/python3.11/site-packages/strawberry/schema/execute.py", line 156, in execute
grai-server-the_guide-1           |     process_errors(result.errors, execution_context)
edlouth commented 1 year ago

@FlavSF thanks for getting in touch with this issue.

Grai uses Algolia for search and this issue is caused by not having it set up. See the docs here https://docs.grai.io/web-app/setup-search for instructions on how to setup Algolia for a self hosted instance. Alternatively everything is already configured on Grai Cloud.

I have made a small tweak, so that the error message is more informative.