loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(repo): return code 400 instead of 500 for invalid archive type (#7029)

The error handled might be non-nil only when format is bad, which is 400 (Bad Request)

Fixes #7026

Signed-off-by: Dmitrii Sharshakov <d3dx12.xx@gmail.com>
Co-authored-by: 0ko <0ko@noreply.codeberg.org>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7029
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
Co-authored-by: Dmitrii Sharshakov <d3dx12.xx@gmail.com>
Co-committed-by: Dmitrii Sharshakov <d3dx12.xx@gmail.com>

authored by

Dmitrii Sharshakov
0ko
Dmitrii Sharshakov
and committed by
0ko
6fb069cc 17db5f37

+6 -2
+2 -2
routers/web/repo/repo.go
··· 474 474 uri := ctx.Params("*") 475 475 ext, tp, err := archiver_service.ParseFileName(uri) 476 476 if err != nil { 477 - ctx.ServerError("ParseFileName", err) 477 + ctx.NotFound("ParseFileName", err) 478 478 return 479 479 } 480 480 aReq, err := archiver_service.NewRequest(ctx, ctx.Repo.Repository.ID, ctx.Repo.GitRepo, strings.TrimSuffix(uri, ext), tp) ··· 554 554 uri := ctx.Params("*") 555 555 ext, tp, err := archiver_service.ParseFileName(uri) 556 556 if err != nil { 557 - ctx.ServerError("ParseFileName", err) 557 + ctx.NotFound("ParseFileName", err) 558 558 return 559 559 } 560 560 aReq, err := archiver_service.NewRequest(ctx, ctx.Repo.Repository.ID, ctx.Repo.GitRepo, strings.TrimSuffix(uri, ext), tp)
+4
tests/integration/repo_archive_test.go
··· 39 39 require.NoError(t, err) 40 40 assert.Empty(t, resp.Header().Get("Content-Encoding")) 41 41 assert.Len(t, bs, 320) 42 + 43 + // Verify that unrecognized archive type returns 404 44 + req = NewRequest(t, "GET", "/user2/repo1/archive/master.invalid") 45 + MakeRequest(t, req, http.StatusNotFound) 42 46 } 43 47 44 48 func TestRepoDownloadArchiveSubdir(t *testing.T) {