From 5c1317c759c4b94ed622ebbf4c646e62c1884f90 Mon Sep 17 00:00:00 2001 From: Arunavo Ray Date: Sun, 26 Apr 2026 13:43:40 +0530 Subject: [PATCH] feat: warn when Forgejo destination has known mirror-credential bug (refs #263) Forgejo < 15.0.0 silently discards auth_username/auth_password sent to /api/v1/repos/migrate, causing subsequent pull-mirror sync of private repos to fail with `terminal prompts disabled`. Fix landed upstream in Forgejo v15.0.0 via codeberg.org/forgejo/forgejo/pulls/11909 and was not backported to v12/v13/v14. Test-connection endpoint now also probes /api/v1/version, detects Forgejo via the `+gitea-` suffix, and surfaces a warning Alert in the Gitea config form when the connected server reports a major version below 15. --- src/components/config/GiteaConfigForm.tsx | 33 ++++++++++++++++++++++- src/lib/api.ts | 18 ++++++++++--- src/pages/api/gitea/test-connection.ts | 33 ++++++++++++++++++++++- 3 files changed, 78 insertions(+), 6 deletions(-) diff --git a/src/components/config/GiteaConfigForm.tsx b/src/components/config/GiteaConfigForm.tsx index e63d447..e95d9fb 100644 --- a/src/components/config/GiteaConfigForm.tsx +++ b/src/components/config/GiteaConfigForm.tsx @@ -6,7 +6,9 @@ import { CardHeader, CardTitle, } from "@/components/ui/card"; -import { giteaApi } from "@/lib/api"; +import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; +import { AlertTriangle } from "lucide-react"; +import { giteaApi, type GiteaServerInfo } from "@/lib/api"; import type { GiteaConfig, MirrorStrategy } from "@/types/config"; import { toast } from "sonner"; import { OrganizationStrategy } from "./OrganizationStrategy"; @@ -23,6 +25,7 @@ interface GiteaConfigFormProps { export function GiteaConfigForm({ config, setConfig, onAutoSave, isAutoSaving, githubUsername }: GiteaConfigFormProps) { const [isLoading, setIsLoading] = useState(false); + const [serverInfo, setServerInfo] = useState(null); // Derive the mirror strategy from existing config for backward compatibility const getMirrorStrategy = (): MirrorStrategy => { @@ -128,13 +131,16 @@ export function GiteaConfigForm({ config, setConfig, onAutoSave, isAutoSaving, g try { const result = await giteaApi.testConnection(config.url, config.token); if (result.success) { + setServerInfo(result.serverInfo ?? null); toast.success("Successfully connected to Gitea!"); } else { + setServerInfo(null); toast.error( "Failed to connect to Gitea. Please check your URL and token." ); } } catch (error) { + setServerInfo(null); toast.error( error instanceof Error ? error.message : "An unknown error occurred" ); @@ -162,6 +168,31 @@ export function GiteaConfigForm({ config, setConfig, onAutoSave, isAutoSaving, g + {serverInfo?.type === "forgejo" && serverInfo.hasMirrorCredBug && ( + + + + Forgejo {serverInfo.version} has a known mirror-credential bug + + +

+ Pull-mirror credentials sent via Forgejo's migrate API aren't persisted on this version, so subsequent syncs of private repos fail with terminal prompts disabled. Fixed in Forgejo 15.0.0 ( + + PR #11909 + + ). +

+

+ Upgrade Forgejo to 15.0.0 or later, then delete and re-mirror affected repos — or open each repo's Settings → Mirror Settings in Forgejo and re-enter the GitHub token once. +

+
+
+ )}