sourcebot-dev / sourcebot

Blazingly fast code search 🏎️ Deployed as a single Docker image 📦 Search million+ lines of code in your GitHub, GitLab, and Gitea repositories 🪄 MIT licensed ✅
https://sourcebot.dev
MIT License
1.16k stars 37 forks source link

RequestError [HttpError]: getaddrinfo ENOTFOUND api.github.com #53

Closed OpenCode closed 3 weeks ago

OpenCode commented 4 weeks ago

I'm using this configuration file

{
    "$schema": "https://raw.githubusercontent.com/sourcebot-dev/sourcebot/main/schemas/v2/index.json",
    "repos": [
        {
            "type": "github",
            "token": {
                "env": "GITHUB_TOKEN"
            },
            "repos": [
                "MY_ORG/MY_REPO"
            ]
        }
    ]
}

where MY_ORG and MY_REPO are my company org and a repo from this org.

When I run docker with:

docker run -e GITHUB_TOKEN=MY_TOKEN -p 3000:3000 --rm --name sourcebot -v $(pwd):/data -e CONFIG_PATH=/data/my_config.json ghcr.io/sourcebot-dev/sourcebot:main

where MY_TOKEN is my github token

I receive this error in log:

[Info] Sourcebot version: main
[Info] Using config file at: '/data/my_config.json'.
2024-10-28 16:32:22,582 CRIT Supervisor is running as root.  Privileges were not dropped because no user is specified in the config file.  If you intend to run as root, you can set user=root in the config file to avoid this message.
2024-10-28 16:32:22,583 INFO supervisord started with pid 7
2024-10-28 16:32:23,586 INFO spawned: 'backend' with pid 132
2024-10-28 16:32:23,588 INFO spawned: 'web' with pid 133
2024-10-28 16:32:23,590 INFO spawned: 'zoekt' with pid 134
[web] |   ▲ Next.js 14.2.10
[web] |   - Local:        http://localhost:3000
[web] |   - Network:      http://0.0.0.0:3000
[web] |
[web] |  ✓ Starting...
[backend] | 2024-10-28T16:32:23.780Z info: [main] Syncing configuration file /data/my_config.json ...
[web] |  ✓ Ready in 63ms
[backend] | GET /repos/MY_ORG/MY_REPO - 500 with id UNKNOWN in 71ms
[backend] | 2024-10-28T16:32:23.857Z error: [main] Failed to sync configuration file /data/my_config.json with error:
[backend] | RequestError [HttpError]: getaddrinfo ENOTFOUND api.github.com
[backend] |     at fetchWrapper (file:///app/node_modules/@octokit/request/dist-bundle/index.js:73:26)
[backend] |     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[backend] |     at async file:///app/packages/backend/dist/github.js:138:24
[backend] |     ... 4 lines matching cause stack trace ...
[backend] |     at async measure (file:///app/packages/backend/dist/utils.js:3:18) {
[backend] |   status: 500,
[backend] |   request: {
[backend] |     method: 'GET',
[backend] |     url: 'https://api.github.com/repos/MY_ORG/MY_REPO',
[backend] |     headers: {
[backend] |       accept: 'application/vnd.github.v3+json',
[backend] |       'user-agent': 'octokit-rest.js/21.0.2 octokit-core.js/6.1.2 Node.js/18.20.4 (linux; x64)',
[backend] |       authorization: 'token [REDACTED]'
[backend] |     },
[backend] |     request: { hook: [Function: bound bound register], signal: [AbortSignal] }
[backend] |   },
[backend] |   response: undefined,
[backend] |   cause: TypeError: fetch failed
[backend] |       at node:internal/deps/undici/undici:12618:11
[backend] |       at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[backend] |       at async fetchWrapper (file:///app/node_modules/@octokit/request/dist-bundle/index.js:47:21)
[backend] |       at async file:///app/packages/backend/dist/github.js:138:24
[backend] |       at async Promise.all (index 0)
[backend] |       at async getRepos (file:///app/packages/backend/dist/github.js:134:19)
[backend] |       at async getGitHubReposFromConfig (file:///app/packages/backend/dist/github.js:20:24)
[backend] |       at async syncConfig (file:///app/packages/backend/dist/index.js:58:37)
[backend] |       at async measure (file:///app/packages/backend/dist/utils.js:3:18) {
[backend] |     cause: Error: getaddrinfo ENOTFOUND api.github.com
[backend] |         at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26) {
[backend] |       errno: -3008,
[backend] |       code: 'ENOTFOUND',
[backend] |       syscall: 'getaddrinfo',
[backend] |       hostname: 'api.github.com'
[backend] |     }
[backend] |   }
[backend] | }
2024-10-28 16:32:24,862 INFO success: backend entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2024-10-28 16:32:24,862 INFO success: web entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2024-10-28 16:32:24,862 INFO success: zoekt entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
OpenCode commented 4 weeks ago

This happens with public repo, too.

{
    "$schema": "https://raw.githubusercontent.com/sourcebot-dev/sourcebot/main/schemas/v2/index.json",
    "repos": [
        {
            "type": "github",
            "repos": [
                "OCA/sale-workflow"
            ]
        }
    ]
}
[Info] Sourcebot version: main
[Info] Using config file at: '/data/my_config.json'.
2024-10-28 16:40:36,694 CRIT Supervisor is running as root.  Privileges were not dropped because no user is specified in the config file.  If you intend to run as root, you can set user=root in the config file to avoid this message.
2024-10-28 16:40:36,695 INFO supervisord started with pid 6
2024-10-28 16:40:37,699 INFO spawned: 'backend' with pid 131
2024-10-28 16:40:37,701 INFO spawned: 'web' with pid 132
2024-10-28 16:40:37,703 INFO spawned: 'zoekt' with pid 133
[web] |   ▲ Next.js 14.2.10
[web] |   - Local:        http://localhost:3000
[web] |   - Network:      http://0.0.0.0:3000
[web] |
[web] |  ✓ Starting...
[web] |  ✓ Ready in 56ms
[backend] | 2024-10-28T16:40:37.965Z info: [main] Syncing configuration file /data/my_config.json ...
[backend] | GET /repos/OCA/sale-workflow - 500 with id UNKNOWN in 70ms
[backend] | 2024-10-28T16:40:38.041Z error: [main] Failed to sync configuration file /data/my_config.json with error:
[backend] | RequestError [HttpError]: getaddrinfo ENOTFOUND api.github.com
[backend] |     at fetchWrapper (file:///app/node_modules/@octokit/request/dist-bundle/index.js:73:26)
[backend] |     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[backend] |     at async file:///app/packages/backend/dist/github.js:138:24
[backend] |     ... 4 lines matching cause stack trace ...
[backend] |     at async measure (file:///app/packages/backend/dist/utils.js:3:18) {
[backend] |   status: 500,
[backend] |   request: {
[backend] |     method: 'GET',
[backend] |     url: 'https://api.github.com/repos/OCA/sale-workflow',
[backend] |     headers: {
[backend] |       accept: 'application/vnd.github.v3+json',
[backend] |       'user-agent': 'octokit-rest.js/21.0.2 octokit-core.js/6.1.2 Node.js/18.20.4 (linux; x64)'
[backend] |     },
[backend] |     request: { hook: [Function: bound bound register], signal: [AbortSignal] }
[backend] |   },
[backend] |   response: undefined,
[backend] |   cause: TypeError: fetch failed
[backend] |       at node:internal/deps/undici/undici:12618:11
[backend] |       at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[backend] |       at async fetchWrapper (file:///app/node_modules/@octokit/request/dist-bundle/index.js:47:21)
[backend] |       at async file:///app/packages/backend/dist/github.js:138:24
[backend] |       at async Promise.all (index 0)
[backend] |       at async getRepos (file:///app/packages/backend/dist/github.js:134:19)
[backend] |       at async getGitHubReposFromConfig (file:///app/packages/backend/dist/github.js:20:24)
[backend] |       at async syncConfig (file:///app/packages/backend/dist/index.js:58:37)
[backend] |       at async measure (file:///app/packages/backend/dist/utils.js:3:18) {
[backend] |     cause: Error: getaddrinfo ENOTFOUND api.github.com
[backend] |         at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26) {
[backend] |       errno: -3008,
[backend] |       code: 'ENOTFOUND',
[backend] |       syscall: 'getaddrinfo',
[backend] |       hostname: 'api.github.com'
[backend] |     }
[backend] |   }
[backend] | }
2024-10-28 16:40:39,044 INFO success: backend entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2024-10-28 16:40:39,045 INFO success: web entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2024-10-28 16:40:39,045 INFO success: zoekt entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
brendan-kellam commented 4 weeks ago

Heya - thanks for raising. I tried reproducing using the public config but was unable to hit the issue.

RequestError [HttpError]: getaddrinfo ENOTFOUND api.github.com looks like the DNS lookup is failing for some reason - maybe something todo with the environment you are running the container? Could you try running curl https://api.github.com/repos/OCA/sale-workflow in a shell within a running Sourcebot container?

OpenCode commented 4 weeks ago

Heya - thanks for raising. I tried reproducing using the public config but was unable to hit the issue.

RequestError [HttpError]: getaddrinfo ENOTFOUND api.github.com looks like the DNS lookup is failing for some reason - maybe something todo with the environment you are running the container? Could you try running curl https://api.github.com/repos/OCA/sale-workflow in a shell within a running Sourcebot container?

curl works fine. I receive the JSON response.

OpenCode commented 3 weeks ago

If I try to use this docker compose file:

  sourcebot:
    image: ghcr.io/sourcebot-dev/sourcebot:latest
    container_name: sourcebot
    ports:
      - "3000:3000"
    volumes:
      - .:/data
    environment:
      - CONFIG_PATH=/data/my_config.json
    restart: unless-stopped

with this conf file

{
    "$schema": "https://raw.githubusercontent.com/sourcebot-dev/sourcebot/main/schemas/v2/index.json",
    "repos": [
        {
            "type": "github",
            "repos": [
                "torvalds/linux"
            ]
        }
    ]
}

I have the same problem.

This is the result of the command docker compose exec sourcebot cat /etc/resolv.conf (if it can helps)

# Generated by Docker Engine.
# This file can be edited; Docker Engine will not make further changes once it
# has been modified.

nameserver 127.0.0.11
options ndots:0

# Based on host file: '/etc/resolv.conf' (internal resolver)
# ExtServers: [192.168.1.1]
# Overrides: []
# Option ndots from: internal
brendan-kellam commented 3 weeks ago

Could you share your docker version? docker version

OpenCode commented 3 weeks ago

Could you share your docker version? docker version

Client: Docker Engine - Community
 Version:           27.3.1
 API version:       1.47
 Go version:        go1.22.7
 Git commit:        ce12230
 Built:             Fri Sep 20 11:41:11 2024
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          27.3.1
  API version:      1.47 (minimum version 1.24)
  Go version:       go1.22.7
  Git commit:       41ca978
  Built:            Fri Sep 20 11:41:11 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.22
  GitCommit:        7f7fdf5fed64eb6a7caf99b3e12efcf9d60e311c
 runc:
  Version:          1.1.14
  GitCommit:        v1.1.14-0-g2c9f560
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
brendan-kellam commented 3 weeks ago

hmm I have the same Docker version. From reading the docs, it seems like docker inherits the DNS configuration of the host machine, so possibly something todo with the DNS setup on your host is causing this?

For good measure, could you try running with --dns=8.8.8.8 in the docker run command?

OpenCode commented 3 weeks ago

hmm I have the same Docker version. From reading the docs, it seems like docker inherits the DNS configuration of the host machine, so possibly something todo with the DNS setup on your host is causing this?

For good measure, could you try running with --dns=8.8.8.8 in the docker run command?

It works!

brendan-kellam commented 3 weeks ago

Great! Going to close this issue since this workaround works. Feel free to re-open if it comes back up.