fix(workspace-server/plugins): fast-fail gitea:// private repo installs via archive API #3153
Reference in New Issue
Block a user
Delete Branch "feat/gitea-private-repo-fastfail"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #3108.
The workspace-server
GiteaResolverusedgit clonefor all HTTP(S) remotes. For private repos the clone hung on a credential prompt until the gateway timed out (~100 s → HTTP 502). This change replaces the clone with an authenticated Gitea archive/tarball API call that fast-fails on 401/403/404.What changed:
GiteaResolver.Fetchfor HTTP(S) now downloads/api/v1/repos/{owner}/{repo}/archive/{ref}.tar.gzusing the existingMOLECULE_TEMPLATE_REPO_TOKENin anAuthorizationheader.ErrPluginNotFound.LastFetchSHAandResolveRefnow use the Gitea commits API with the same auth/timeout behavior.file://remotes (test fixtures) keep the original git-clone path.Local testing:
All existing real-git tests pass; new archive-path tests cover private-repo fast-fail, timeout, successful whole-repo install, subpath isolation, and API-based
ResolveRef.SOP Checklist
./internal/plugins/suite.feedback_phantom_required_check_after_gitea_migration(BP context patterns), existing gitea resolver security model (BASE-ref script), CP PR#850 token provisioning.Replace the git-clone path for HTTP(S) Gitea remotes with an authenticated Gitea archive/tarball API call. This avoids the ~100 s credential-prompt hang on private repos that surfaced as a 502 gateway timeout. - Fetch now downloads /api/v1/repos/{owner}/{repo}/archive/{ref}.tar.gz with the existing MOLECULE_TEMPLATE_REPO_TOKEN in an Authorization header. - 401/403/404 map to clear, token-safe errors; 404 resolves to ErrPluginNotFound. - A bounded timeout (default 30 s) ensures unreachable/private repos fail fast. - SHA resolution for LastFetchSHA and ResolveRef also moves to the Gitea commits API with the same timeout and fail-closed auth handling. - file:// remotes (test fixtures) keep the original git-clone behavior. Adds regression tests for private-repo fast-fail (401/403/404), timeout, successful archive install, subpath isolation, and ResolveRef via API. Fixes #3108 Co-Authored-By: Claude <noreply@anthropic.com>APPROVED on current head
ea32eeee8f.5-axis review:
Note: I could not run local Go tests because this runtime has no go binary; Gitea CI is still running and should remain the merge gate.
5-axis current-head review clean. The HTTP(S) gitea:// path now uses the authenticated Gitea archive/commits APIs with the existing MOLECULE_TEMPLATE_REPO_TOKEN env source, no hardcoded token, and token-free error strings. 401/403 fail fast as inaccessible, 404 maps to ErrPluginNotFound, and archive/SHA resolution are bounded by timeout. file:// fixtures remain on the git path. Regression tests cover private-repo fast-fail, timeout, archive success, subpath isolation, ResolveRef, and tag ref normalization.