Title: [bug] Gitea sync fails with ERR_STREAM_PREMATURE_CLOSE, then crashes on null full_name · Issue #1404 · sourcebot-dev/sourcebot · GitHub
Open Graph Title: [bug] Gitea sync fails with ERR_STREAM_PREMATURE_CLOSE, then crashes on null full_name · Issue #1404 · sourcebot-dev/sourcebot
X Title: [bug] Gitea sync fails with ERR_STREAM_PREMATURE_CLOSE, then crashes on null full_name · Issue #1404 · sourcebot-dev/sourcebot
Description: Describe the bug Bug description When syncing repositories from a self-hosted Gitea instance, Sourcebot fails the connection sync job with: Cannot read properties of null (reading 'full_name') After debugging, the root cause appears to b...
Open Graph Description: Describe the bug Bug description When syncing repositories from a self-hosted Gitea instance, Sourcebot fails the connection sync job with: Cannot read properties of null (reading 'full_name') Afte...
X Description: Describe the bug Bug description When syncing repositories from a self-hosted Gitea instance, Sourcebot fails the connection sync job with: Cannot read properties of null (reading 'full_name...
Opengraph URL: https://github.com/sourcebot-dev/sourcebot/issues/1404
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[bug] Gitea sync fails with ERR_STREAM_PREMATURE_CLOSE, then crashes on null full_name","articleBody":"### Describe the bug\n\n## Bug description\n\nWhen syncing repositories from a self-hosted Gitea instance, Sourcebot fails the connection sync job with:\n\n```text\nCannot read properties of null (reading 'full_name')\n```\n\nAfter debugging, the root cause appears to be that gitea-js / cross-fetch fails while reading the Gitea API response body with:\n\n```text\nERR_STREAM_PREMATURE_CLOSE\n```\n\nThis causes api.repos.repoGet() to return:\n\n```json\n\n{\n \"size\": 0,\n \"timeout\": 0,\n \"data\": null,\n \"error\": {\n \"message\": \"Invalid response body while trying to fetch http://xxxxx:3001/api/v1/repos/xxxx/xxx.xxxx: Premature close\",\n \"type\": \"system\",\n \"errno\": \"ERR_STREAM_PREMATURE_CLOSE\",\n \"code\": \"ERR_STREAM_PREMATURE_CLOSE\"\n }\n}\n```\nSourcebot then executes this code in /app/packages/backend/dist/gitea.js:\n\n```javascript\n\nreturn {\n type: 'valid',\n data: [response.data]\n};\n```\nSince response.data is null, allRepos contains null. Later this crashes:\n\n```javascript\nallRepos = allRepos.filter(repo =\u003e repo.full_name !== undefined);\n```\n\n\n\n\n\n\n### To reproduce\n\nInside the Sourcebot container:\n\n```javascript\nimport { giteaApi } from \"gitea-js\";\nimport fetch from \"cross-fetch\";\n\nconst api = giteaApi(\"http://gitea:3001\", {\n token: process.env.GITEA_TOKEN,\n customFetch: fetch,\n});\n\nconst response = await api.repos.repoGet(\"Org\", \"Repo\");\n\nconsole.log(JSON.stringify(response, null, 2));\n```\n\n```json\n\n{\n \"size\": 0,\n \"timeout\": 0,\n \"data\": null,\n \"error\": {\n \"message\": \"Invalid response body while trying to fetch http://gitea:3001/api/v1/repos/Fairparken/Fairparken.Worker: Premature close\",\n \"type\": \"system\",\n \"errno\": \"ERR_STREAM_PREMATURE_CLOSE\",\n \"code\": \"ERR_STREAM_PREMATURE_CLOSE\"\n }\n}\n```\n\n### Sourcebot deployment information\n\nSourcebot version (e.g. v3.0.1): V5.0.4\nGittea image version: docker.gitea.com/gitea:1.26.1-rootless\n\n\n### Additional information\n\nTemporary workaround tested:\n\nI patched /app/packages/backend/dist/gitea.js inside the running Sourcebot container to use a custom fetch:\n\n```javascript\nconst customFetch = (url, options = {}) =\u003e {\n const headers = {\n ...(options.headers ?? {}),\n 'Accept-Encoding': 'identity',\n 'Connection': 'close',\n };\n\n return fetch(url, {\n ...options,\n headers,\n });\n};\n\nconst api = giteaApi(config.url ?? 'https://gitea.com', {\n token: token,\n customFetch,\n});\n```\n\nI also added a null guard:\n```javascript\n\nallRepos = allRepos.filter((repo, index) =\u003e {\n if (repo === null || repo === undefined) {\n logger.warn(`Skipping null/undefined Gitea repo at index ${index}`);\n return false;\n }\n return repo.full_name !== undefined;\n});\n```\n\n# Relevant code locations\n/app/packages/backend/dist/gitea.js:42\n/app/packages/backend/dist/gitea.js:161-166\n/app/packages/backend/dist/repoCompileUtils\n\n\n\n","author":{"url":"https://github.com/HueskenNiels-hue","@type":"Person","name":"HueskenNiels-hue"},"datePublished":"2026-06-30T09:31:24.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/1404/sourcebot/issues/1404"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:dd85afae-b98c-26fe-9040-638e0d9eb7dd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 841E:18D9A8:23E96B6:32F25CF:6A4CDFF8 |
| html-safe-nonce | 7275965cd79541f56f0a8fc69b64ffc0e387c4700e72c6be5344db55007623c5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NDFFOjE4RDlBODoyM0U5NkI2OjMyRjI1Q0Y6NkE0Q0RGRjgiLCJ2aXNpdG9yX2lkIjoiMjgzOTc1NDgzMjI2NDA5MzY4OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f49c02d50285d9a658640896ae42eaccd9789c42036cd0e61d80c0a2e865f5da |
| hovercard-subject-tag | issue:4775493901 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/sourcebot-dev/sourcebot/1404/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ae86ea708b8f623651656c0bf1af8b37ed5bc4c9ae9d3c99b45f95dadbc93c67/sourcebot-dev/sourcebot/issues/1404 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ae86ea708b8f623651656c0bf1af8b37ed5bc4c9ae9d3c99b45f95dadbc93c67/sourcebot-dev/sourcebot/issues/1404 |
| og:image:alt | Describe the bug Bug description When syncing repositories from a self-hosted Gitea instance, Sourcebot fails the connection sync job with: Cannot read properties of null (reading 'full_name') Afte... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | HueskenNiels-hue |
| hostname | github.com |
| expected-hostname | github.com |
| None | 299b43bca6e02ad35197ffeba30d2466846d5fb02ab96fbced5b5e6cec589fb8 |
| turbo-cache-control | no-preview |
| go-import | github.com/sourcebot-dev/sourcebot git https://github.com/sourcebot-dev/sourcebot.git |
| octolytics-dimension-user_id | 135396723 |
| octolytics-dimension-user_login | sourcebot-dev |
| octolytics-dimension-repository_id | 846729675 |
| octolytics-dimension-repository_nwo | sourcebot-dev/sourcebot |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 846729675 |
| octolytics-dimension-repository_network_root_nwo | sourcebot-dev/sourcebot |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3eeb74f55ccd8a31bdaec6839577c592bbf7844c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width