Skip to content

fix: server startup panic (DI) and git clone auth against self-hosted GitLab#1

Open
yg-codes wants to merge 2 commits into
antlss:mainfrom
yg-codes:fix/server-di-and-clone-auth
Open

fix: server startup panic (DI) and git clone auth against self-hosted GitLab#1
yg-codes wants to merge 2 commits into
antlss:mainfrom
yg-codes:fix/server-di-and-clone-auth

Conversation

@yg-codes

@yg-codes yg-codes commented Jul 7, 2026

Copy link
Copy Markdown

1. fix(server): initialize store container before worker pool

cmd/server panics on startup for every STORE_DRIVER:

panic: DI: could not find service .../domain.ReviewJobStore,
path: worker.Pool -> review.Pipeline -> ReviewJobStore

provideStores (internal/di/infra.go) registers the individual store interfaces (ReviewJobStore, ReplyJobStore, …) as a side effect and is do.Lazy. In cmd/server the first invoke that needs them is worker.Pool, and nothing invokes *store.Stores first, so the
registrations never run. The CLI works only because it invokes *store.Stores early.

Fix: eagerly invoke *store.Stores right after config validation in cmd/server/main.go, mirroring the CLI.

2. fix(git): authenticate clone/fetch with oauth2 URL, not PRIVATE-TOKEN header

Review jobs enqueue, then the clone fails:

fatal: could not read Username for 'https://gitlab...': No such device or address

internal/pkg/git/manager.go authenticates the git CLI with http.extraHeader: PRIVATE-TOKEN. GitLab's git-over-HTTP smart protocol does not honor PRIVATE-TOKEN (nor Authorization: Bearer) — only oauth2:<token> basic-auth in the URL works. Verified against GitLab
18.11.3:

git -c http.extraHeader="PRIVATE-TOKEN: $T" ls-remote # fails (prompts for username)
git ls-remote "https://oauth2:$T@host/.git" # works

So the CLI got a 401 and fell back to interactive prompting (fails in a service context); it only limped along via the slow go-git fallback.

Fix: build the clone URL with oauth2:<token> embedded (authCloneURL), and set GIT_TERMINAL_PROMPT=0 so auth failures fail fast instead of hanging.

Trade-off note: embedding the token persists it in <repo>/.git/config. A credential helper would avoid on-disk storage — happy to switch to that if you prefer.

yg-codes added 2 commits July 7, 2026 08:16
The server paniced on startup with 'could not find service ReviewJobStore'
for every store driver. provideStores registers the individual store
interfaces (ReviewJobStore, ReplyJobStore, ...) as a side effect and is
lazy; cmd/server invokes worker.Pool first, which needs those interfaces
before anything invokes *store.Stores, so the registrations never ran.
Eagerly invoke *store.Stores after config validation, mirroring the CLI.
… header

GitLab's git-over-HTTP smart protocol does not honor the 'PRIVATE-TOKEN'
http.extraHeader (nor Authorization: Bearer) used for API calls, so the CLI
clone got 401 and fell back to interactive username prompting, failing with
'could not read Username' in a non-interactive context. Build the clone URL
with oauth2:<token> basic-auth embedded (the method GitLab accepts for git
transport) and set GIT_TERMINAL_PROMPT=0 so auth failures fail fast instead
of hanging. The slow go-git fallback is no longer routinely hit.
@yg-codes yg-codes changed the title Fix/server di and clone auth fix: server startup panic (DI) and git clone auth against self-hosted GitLab Jul 7, 2026
@yg-codes yg-codes changed the title fix: server startup panic (DI) and git clone auth against self-hosted GitLab fix: server startup panic (DI) and git clone auth against self-hosted GitLab Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant