Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Cant acces user and more data from supabase #2405

Closed
zulfaiflakhul opened this issue Apr 3, 2024 · 7 comments
Closed

[Bug]: Cant acces user and more data from supabase #2405

zulfaiflakhul opened this issue Apr 3, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@zulfaiflakhul
Copy link

What happened?

I installed Quivr offline using Docker, when I accessed the user with Swager Fast Api an error appeared as below

Relevant log output

File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 66, in map_httpcore_exceptions
    yield
  File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 228, in handle_request
    resp = self._pool.handle_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpcore/_sync/connection_pool.py", line 216, in handle_request
    raise exc from None
  File "/usr/local/lib/python3.11/site-packages/httpcore/_sync/connection_pool.py", line 196, in handle_request
    response = connection.handle_request(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpcore/_sync/connection.py", line 99, in handle_request
    raise exc
  File "/usr/local/lib/python3.11/site-packages/httpcore/_sync/connection.py", line 76, in handle_request
    stream = self._connect(request)
             ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpcore/_sync/connection.py", line 122, in _connect
    stream = self._network_backend.connect_tcp(**kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpcore/_backends/sync.py", line 205, in connect_tcp
    with map_exceptions(exc_map):
  File "/usr/local/lib/python3.11/contextlib.py", line 155, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/usr/local/lib/python3.11/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
    raise to_exc(exc) from exc
httpcore.ConnectError: [Errno -2] Name or service not known

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/uvicorn/protocols/http/h11_impl.py", line 408, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 69, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "/usr/local/lib/python3.11/site-packages/starlette/applications.py", line 123, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/usr/local/lib/python3.11/site-packages/starlette/middleware/errors.py", line 186, in __call__
    raise exc
  File "/usr/local/lib/python3.11/site-packages/starlette/middleware/errors.py", line 164, in __call__
    await self.app(scope, receive, _send)
  File "/usr/local/lib/python3.11/site-packages/starlette/middleware/cors.py", line 83, in __call__
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 758, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 778, in app
    await route.handle(scope, receive, send)
  File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 299, in handle
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 79, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 74, in app
    response = await func(request)
               ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/fastapi/routing.py", line 278, in app
    raw_response = await run_endpoint_function(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/fastapi/routing.py", line 191, in run_endpoint_function
    return await dependant.call(**values)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/code/modules/user/controller/user_controller.py", line 37, in get_user_endpoint
    user_settings = user_daily_usage.get_user_settings()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/code/models/user_usage.py", line 40, in get_user_settings
    request = self.supabase_db.get_user_settings(self.id)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/code/models/databases/supabase/user_usage.py", line 178, in get_user_settings
    .execute()
     ^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/postgrest/_sync/request_builder.py", line 58, in execute
    r = self.session.request(
        ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 814, in request
    return self.send(request, auth=auth, follow_redirects=follow_redirects)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 901, in send
    response = self._send_handling_auth(
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 929, in _send_handling_auth
    response = self._send_handling_redirects(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 966, in _send_handling_redirects
    response = self._send_single_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1002, in _send_single_request
    response = transport.handle_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 227, in handle_request
    with map_httpcore_exceptions():
  File "/usr/local/lib/python3.11/contextlib.py", line 155, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 83, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.ConnectError: [Errno -2] Name or service not known

Twitter / LinkedIn details

No response

@zulfaiflakhul zulfaiflakhul added the bug Something isn't working label Apr 3, 2024
Copy link

dosubot bot commented Apr 3, 2024

Hey again, @zulfaiflakhul! 👋 Good to see you diving deeper into Quivr. Let's tackle this issue together.

Based on the error message you provided, it seems like you're encountering a DNS resolution issue. This typically happens when the service (in this case, Supabase) cannot be found under the given hostname. This can occur due to various reasons, but in the context of Docker, it's often related to how Docker handles DNS or network configurations.

Here are some steps you can take to resolve this issue:

  1. Check Network Configuration: Ensure your Docker container can access the internet. You can test this by executing a command like docker exec <container_id> ping google.com from your host machine. If this fails, you might need to adjust your Docker network settings.

  2. DNS Configuration in Docker: Docker uses the default 8.8.8.8 (Google DNS) and 8.8.4.4 for DNS resolution. If your network blocks these, or if you need to use a different DNS, you can configure Docker to use custom DNS servers. This is done by editing the Docker daemon configuration file (usually located at /etc/docker/daemon.json) and adding the dns key:

    {
      "dns": ["your_dns_server", "secondary_dns_server"]
    }

    After making changes, restart the Docker daemon.

  3. Hardcode Supabase Host IP: As a temporary workaround, you could find the IP address of the Supabase service (using a tool like nslookup or dig) and hardcode it in your application or Docker's hosts file. This is not recommended for production but can help verify if DNS resolution is the issue.

  4. Use Docker's --network=host Option: Running your container with the host's network stack can sometimes resolve DNS issues. This can be done by adding --network=host to your docker run command. Note that this option is not available on Docker for Windows when using Windows containers.

  5. Inspect Firewall or Network Policies: Ensure that no firewall or network policy is blocking the DNS queries or the connection to Supabase.

  6. Review Supabase Client Configuration: Double-check the Supabase client configuration in your FastAPI application. Ensure that the Supabase URL is correctly specified and accessible from within the Docker container.

  7. Debugging Inside the Container: If the issue persists, you can debug inside the container by installing DNS utilities (e.g., dnsutils package in Debian/Ubuntu) and using commands like dig or nslookup to manually check DNS resolution for the Supabase service.

Remember to rebuild your Docker image and restart your container after making changes to the Dockerfile or Docker configuration to ensure the changes take effect.

Regarding your question about the get_user_settings() function, it is designed to fetch and return the settings for a specific user from the Supabase database. It interacts with Supabase by performing operations such as fetching the user's settings from the user_settings table by filtering the records based on the user_id, creating a new entry in the user_settings table with the user's ID if no settings are found, checking if the user is a premium user, and returning the user settings.

The user_settings table in the Supabase database used by Quivr has the following structure:

create table "public"."user_settings" (
    "user_id" uuid not null,
    "models" jsonb default '["gpt-3.5-turbo-1106"]'::jsonb,
    "daily_chat_credit" integer default 20,
    "max_brains" integer default 3,
    "max_brain_size" integer default 1000000
);

You can find more details about this in the supabase/migrations/20240103173626_init.sql file.

I hope this helps! If you have any more questions or if the issue persists, please provide more details so I can assist you further.

Sources

About Dosu

This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@zulfaiflakhul
Copy link
Author

beat | [2024-04-03 09:25:00,004: INFO/MainProcess] Scheduler: Sending due task process_integration_brain_sync (celery_worker.process_integration_brain_sync)
worker | [2024-04-03 09:25:00,012: INFO/MainProcess] Task celery_worker.process_integration_brain_sync[4c87d24d-0e0d-4452-8448-6ffc5b772a1d] received
worker | [2024-04-03 09:25:00,033: ERROR/ForkPoolWorker-10] Task celery_worker.process_integration_brain_sync[4c87d24d-0e0d-4452-8448-6ffc5b772a1d] raised unexpected: ConnectError('[Errno 111] Connection refused')

How anyone can resolve?

@StanGirard
Copy link
Collaborator

Hey @zulfaiflakhul, did you install on a server ? If yes you need to change some values in the .env as it is not host.docker.internal anymore but your IP address.

@zulfaiflakhul
Copy link
Author

no, I didn't install it on the server, but I installed it locally

@azizbahri
Copy link

httpx.ConnectError: [Errno -2] Name or service not known
I had this exact issue, caused by the network configurations of all the different docker containers running locally.
Try uninstalling docker-engine and install docker-desktop instead.

@jerry0li
Copy link

@StanGirard hi there, I installed Quivr successfully on my server, but when I visit my supabase studio with http://my-ip:54323, and click the authentication botton on the left sidebar in order to add new user. I choose the Create new user method and fill in required blanks. After I press the Create user botton, I get a notification on the top-right cornor saying:

failed to create user: An error has occurred: NetworkError when attempting to fetch resource.

I suppose the reason probably is the IP address which supabase uses the localhost:port instead of my-ip:port.

looking forward to your reply asap. Thx a lot.

@StanGirard
Copy link
Collaborator

Hey my friend, can you try to git pull and rerun the docker compose up ?

Or else, follow this procedure if on your own vps: https://docs.quivr.app/deployment/digital_ocean

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants