Skip Gitea SDK version probe to avoid nil client on unreachable hosts#59
Merged
Skip Gitea SDK version probe to avoid nil client on unreachable hosts#59
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #58.
gitea.NewClientcalls/api/v1/versionduring construction to check the server is at least 1.11. When that request fails (DNS error, connection refused, timeout) it returns(nil, err). We were discarding the error atgitea/gitea.go:27and storing the nil client, so the first real API call would dereference nil and panic.The fix passes
gitea.SetGiteaVersion("")which setsignoreVersion = truein the SDK, making the version check a no-op.NewClientthen never hits the network and never returns nil. Connection failures now surface as ordinary errors on the first real request:This also removes a wasted round-trip on every invocation, since
Newis called at startup for the default codeberg.org registration regardless of which forge the user is actually targeting.The first test reproduces the panic by closing an httptest server before calling into the forge. The second confirms construction no longer hits the version endpoint.