Skip to content

chore(go/http): remove unused extractPayment/createHTTPResponse#2342

Open
feldmannn wants to merge 1 commit into
x402-foundation:mainfrom
feldmannn:fix/go-legacy-conversion
Open

chore(go/http): remove unused extractPayment/createHTTPResponse#2342
feldmannn wants to merge 1 commit into
x402-foundation:mainfrom
feldmannn:fix/go-legacy-conversion

Conversation

@feldmannn
Copy link
Copy Markdown
Contributor

Description

go/http/server.go carries two unexported methods on *x402HTTPResourceServer flagged with //nolint:unused and 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:

  1. Not part of the public API. Both names start with a lowercase letter; they are unexported. Nothing outside the package can call them.

  2. The "V1 to V2 conversion" inside them is illusory. go/types.go:65-74 declares the bare names x402.PaymentPayload, x402.PaymentRequired, x402.PaymentRequirements, and x402.ResourceInfo as Go type aliases of the V2 types:

    type (
        PaymentRequirements = types.PaymentRequirements
        PaymentPayload      = types.PaymentPayload
        PaymentRequired     = types.PaymentRequired
        ResourceInfo        = types.ResourceInfo
    )

    So extractPayment takes a V2 struct, re-wraps it field-by-field into the identical struct, and zeros Accepted with // TODO: Convert. createHTTPResponse does the same shape of work and zeros Resource with // 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.

  3. 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:unused suppressions. 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 0
  • go vet ./...: exit 0
  • go test -cover ./...: exit 0. All packages report ok. The go/http package coverage is 78.8%.
  • golangci-lint run --config .golangci.yml ./http/... (v2.x): 0 issues
  • gofmt -d on the changed file's git blob: 0 lines (gofmt-clean as committed; CI's make fmt will not produce a diff)
  • Caller search: 0 matches for .extractPayment(, .createHTTPResponse(, "extractPayment", "createHTTPResponse" anywhere in go/
  • No //go:generate directives, no reflect.MethodByName usage, no build tags referencing the deleted symbols

-race was 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

  • I have formatted and linted my code
  • All new and existing tests pass
  • My commits are signed (required for merge) -- you may need to rebase if you initially pushed unsigned commits
  • I added a changelog fragment for user-facing changes (skipped: deletion is purely internal/unexported, no Go API change)

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.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 17, 2026

@feldmannn is attempting to deploy a commit to the Coinbase Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added go sdk Changes to core v2 packages labels May 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go sdk Changes to core v2 packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant