chore(go/http): remove unused extractPayment/createHTTPResponse#2342
Open
feldmannn wants to merge 1 commit into
Open
chore(go/http): remove unused extractPayment/createHTTPResponse#2342feldmannn wants to merge 1 commit into
feldmannn wants to merge 1 commit into
Conversation
Both methods were marked //nolint:unused with comments claiming API compatibility, but they are unexported (lowercase names) and thus not part of the public API. No callers exist. Remove to eliminate dead code and the incomplete TODO conversions inside them.
|
@feldmannn is attempting to deploy a commit to the Coinbase Team on Vercel. A member of the Team first needs to authorize it. |
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.
Description
go/http/server.gocarries two unexported methods on*x402HTTPResourceServerflagged with//nolint:unusedand comments claiming they are "kept for API compatibility":extractPayment(adapter HTTPAdapter) *x402.PaymentPayload(line 862)createHTTPResponse(paymentRequired x402.PaymentRequired, ...) (*HTTPResponseInstructions, error)(line 939)Both claims are wrong, and the methods are pure dead duplication of the V2 equivalents:
Not part of the public API. Both names start with a lowercase letter; they are unexported. Nothing outside the package can call them.
The "V1 to V2 conversion" inside them is illusory.
go/types.go:65-74declares the bare namesx402.PaymentPayload,x402.PaymentRequired,x402.PaymentRequirements, andx402.ResourceInfoas Go type aliases of the V2 types:So
extractPaymenttakes a V2 struct, re-wraps it field-by-field into the identical struct, and zerosAcceptedwith// TODO: Convert.createHTTPResponsedoes the same shape of work and zerosResourcewith// TODO: convert. There is no V1 type involved on either side of the "conversion." The TODOs document field-dropping that is unfixable as written: you would either have to re-introduce V1 types that nothing in this code path uses, or write a no-op identity transform, which is what the methods already are once you remove the field-zeroing.Zero callers in Go. Repo-wide grep finds no
.extractPayment(or.createHTTPResponse(call sites in any Go file, and no string-literal references that might be reached via reflection.This PR deletes both methods and their
//nolint:unusedsuppressions. The V2 methods (extractPaymentV2,createHTTPResponseV2) remain and are unaffected.Disclosure: this change was prepared with the help of an AI coding assistant. The deletion was independently verified by grep, by reading the type-alias declarations, and by running the full Go test and lint suite locally before commit.
Tests
Local verification with Go 1.23.4 on Windows, against
main:go build ./...: exit 0go vet ./...: exit 0go test -cover ./...: exit 0. All packages reportok. Thego/httppackage coverage is 78.8%.golangci-lint run --config .golangci.yml ./http/...(v2.x): 0 issuesgofmt -don the changed file's git blob: 0 lines (gofmt-clean as committed; CI'smake fmtwill not produce a diff).extractPayment(,.createHTTPResponse(,"extractPayment","createHTTPResponse"anywhere ingo///go:generatedirectives, noreflect.MethodByNameusage, no build tags referencing the deleted symbols-racewas not exercised locally (no CGO toolchain on this host); the repo's CI race build will catch any (unlikely) race introduced by a pure deletion.Checklist