From 1c9aec0941d3243be797da727aeeb6278430ef90 Mon Sep 17 00:00:00 2001 From: PineBale <272794187+PineBale@users.noreply.github.com> Date: Sat, 18 Apr 2026 16:29:58 +0800 Subject: [PATCH 1/8] await resp.text used twice in handleFetchActionError --- web_src/js/features/common-fetch-action.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_src/js/features/common-fetch-action.ts b/web_src/js/features/common-fetch-action.ts index f3decf53b2abb..879fca8667aa9 100644 --- a/web_src/js/features/common-fetch-action.ts +++ b/web_src/js/features/common-fetch-action.ts @@ -90,7 +90,7 @@ async function handleFetchActionSuccess(el: HTMLElement, opt: FetchActionOpts, r async function handleFetchActionError(resp: Response) { const isRespJson = resp.headers.get('content-type')?.includes('application/json'); const respText = await resp.text(); - const respJson = isRespJson ? JSON.parse(await resp.text()) : null; + const respJson = isRespJson ? JSON.parse(respText) : null; if (respJson?.errorMessage) { // the code was quite messy, sometimes the backend uses "err", sometimes it uses "error", and even "user_error" // but at the moment, as a new approach, we only use "errorMessage" here, backend can use JSONError() to respond. From cf333968fac56775ad63b34912d6d29b5e2e3c5f Mon Sep 17 00:00:00 2001 From: PineBale <272794187+PineBale@users.noreply.github.com> Date: Sat, 18 Apr 2026 16:50:21 +0800 Subject: [PATCH 2/8] handleSettingsPostDelete --- routers/web/repo/setting/setting.go | 6 +++--- templates/repo/settings/options.tmpl | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/routers/web/repo/setting/setting.go b/routers/web/repo/setting/setting.go index 29f3e62b8fc67..d6e126b04fc6d 100644 --- a/routers/web/repo/setting/setting.go +++ b/routers/web/repo/setting/setting.go @@ -887,11 +887,11 @@ func handleSettingsPostDelete(ctx *context.Context) { form := web.GetForm(ctx).(*forms.RepoSettingForm) repo := ctx.Repo.Repository if !ctx.Repo.IsOwner() { - ctx.HTTPError(http.StatusNotFound) + ctx.JSONErrorNotFound() return } if repo.Name != form.RepoName { - ctx.RenderWithErrDeprecated(ctx.Tr("form.enterred_invalid_repo_name"), tplSettingsOptions, nil) + ctx.JSONError(ctx.Tr("form.enterred_invalid_repo_name")) return } @@ -907,7 +907,7 @@ func handleSettingsPostDelete(ctx *context.Context) { log.Trace("Repository deleted: %s/%s", ctx.Repo.Owner.Name, repo.Name) ctx.Flash.Success(ctx.Tr("repo.settings.deletion_success")) - ctx.Redirect(ctx.Repo.Owner.DashboardLink()) + ctx.JSONRedirect(ctx.Repo.Owner.DashboardLink()) } func handleSettingsPostDeleteWiki(ctx *context.Context) { diff --git a/templates/repo/settings/options.tmpl b/templates/repo/settings/options.tmpl index 09c2ab660bfc4..3c966b5dd1688 100644 --- a/templates/repo/settings/options.tmpl +++ b/templates/repo/settings/options.tmpl @@ -946,7 +946,7 @@ {{ctx.Locale.Tr "repo.settings.delete_notices_fork_1"}} {{end}} -