Found while testing #57. If origin points to a Gitea-shaped domain that can't be reached, any command that calls into the Gitea backend panics instead of returning an error.
Repro:
git init
git remote add origin https://gitea.example.com/o/r.git
forge pr list
Stack:
panic: runtime error: invalid memory address or nil pointer dereference
code.gitea.io/sdk/gitea.(*Client).doRequest
client.go:335
code.gitea.io/sdk/gitea.(*Client).ListRepoPullRequests(0x0, ...)
pull.go:133
github.com/git-pkgs/forge/gitea.(*giteaPRService).List
gitea/prs.go:155
The receiver on ListRepoPullRequests is 0x0 — the SDK client is nil.
Cause is gitea/gitea.go:27:
c, _ := gitea.NewClient(baseURL, opts...)
return &giteaForge{client: c, ...}
gitea.NewClient does a network call on construction to fetch the server version (unlike the GitHub and GitLab SDKs which connect lazily). When the host is unreachable it returns (nil, err) and we store the nil. Every subsequent call on the forge dereferences it.
Fix is to either check the error there, or pass gitea.SetGiteaVersion("") to skip the version probe and defer the failure to the first real request.
Found while testing #57. If
originpoints to a Gitea-shaped domain that can't be reached, any command that calls into the Gitea backend panics instead of returning an error.Repro:
Stack:
The receiver on
ListRepoPullRequestsis0x0— the SDK client is nil.Cause is
gitea/gitea.go:27:gitea.NewClientdoes a network call on construction to fetch the server version (unlike the GitHub and GitLab SDKs which connect lazily). When the host is unreachable it returns(nil, err)and we store the nil. Every subsequent call on the forge dereferences it.Fix is to either check the error there, or pass
gitea.SetGiteaVersion("")to skip the version probe and defer the failure to the first real request.