chore: enable forcetypeassert linter, fix issues (#38804)

Enable [`forcetypeassert`](https://github.com/gostaticanalysis/forcetypeassert)
linter to prevent unchecked type assertions. ~650 issues fixed, most
fixes were clean, some use `setting.PanicInDevOrTesting`.

The only behaviour changes are where code would previously send a 500 error
or panic, a 4xx error is now emitted.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
silverwind
2026-08-09 12:25:06 +02:00
committed by GitHub
parent fac8bf2eca
commit 76a81b24f9
248 changed files with 1110 additions and 995 deletions
+5 -2
View File
@@ -16,6 +16,7 @@ import (
"gitea.dev/tests"
"github.com/42wim/httpsig"
"github.com/stretchr/testify/require"
"golang.org/x/crypto/ssh"
)
@@ -112,7 +113,9 @@ func TestHTTPSigCert(t *testing.T) {
keyID := "gitea"
// create our certificate signer using the ssh signer and our certificate
certSigner, err := ssh.NewCertSigner(pkcert.(*ssh.Certificate), sshSigner)
cert, ok := pkcert.(*ssh.Certificate)
require.True(t, ok)
certSigner, err := ssh.NewCertSigner(cert, sshSigner)
if err != nil {
t.Fatal(err)
}
@@ -121,7 +124,7 @@ func TestHTTPSigCert(t *testing.T) {
req = NewRequest(t, "GET", "/api/v1/admin/users")
// add our cert to the request
certString := base64.RawStdEncoding.EncodeToString(pkcert.(*ssh.Certificate).Marshal())
certString := base64.RawStdEncoding.EncodeToString(cert.Marshal())
req.SetHeader("x-ssh-certificate", certString)
signer, _, err := httpsig.NewSSHSigner(certSigner, httpsig.DigestSha512, []string{httpsig.RequestTarget, "(created)", "(expires)", "x-ssh-certificate"}, httpsig.Signature, 10)