Build broken: github/reviews.go duplicates github/review.go — redeclared types and methods #116
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What was missed
The
github/package fails to compile due to duplicate type and method declarations introduced whengithub/reviews.gowas added alongside the existinggithub/review.go. Runninggo build ./...produces:github/review.gowas added in PR #105 with adoRequestWithBodyhelper dependency that was never defined inclient.go.github/reviews.gowas added in PR #106 as a replacement/update, butgithub/review.gowas not removed — leaving both files in the tree and causing the duplicate declarations.Additionally,
github/review.goreferencesc.doRequestWithBodywhich does not exist on*Client.Source
github/review.go(should be deleted or its methods removed)github/reviews.go(the intended current implementation)doRequestWithBody— referenced ingithub/review.go:120,177but never definedWhat needs to happen
github/review.go(its intended content has been superseded bygithub/reviews.go)github/reviews.gohas all necessary method implementations without relying ondoRequestWithBodygo build ./...andgo test ./...passReferences
go build ./...on main branchPlan: Fix build — remove duplicate github/review.go
Problem
github/review.goandgithub/reviews.goboth declare the same types (reviewResponse,dismissReviewRequest) and methods (PostReview,ListReviews,DeleteReview,DismissReview). Additionally,github/identity.godeclaresuserResponseandGetAuthenticatedUserwhich are also inreviews.go. The build fails with redeclaration errors.github/review.goalso referencesc.doRequestWithBodywhich does not exist on*Client.Root Cause
PR #105 added
github/review.gowith adoRequestWithBodydependency. PR #106 addedgithub/reviews.goas a replacement usingdoJSONRequest, but never removedreview.go.Proposed Approach
github/review.go— superseded bygithub/reviews.gogithub/identity.go— itsuserResponsetype andGetAuthenticatedUserare already inreviews.godoJSONRequestmethod toclient.go—reviews.gocalls it but it does not exist. It should marshal a payload to JSON, then perform the HTTP request with Content-Type: application/json.github/review_test.go— referencespostReviewRequest(nowreviewCreateRequest),ErrCannotDeleteSubmittedReview,ErrConflictingCommitIDs, andtranslateGitHubReviewState. Tests that exercise deleted logic should be removed or rewritten against thereviews.goAPI.github/helpers_test.go— callsc.SetRetryBackoff(...)expecting an error return, but the signature returns nothing. Align.go build ./...andgo test ./...passConstraints
vcs.Providercontracts stay the same)reviews.gois the canonical implementation — preserve its behavioridentity_test.go— tests coverGetAuthenticatedUserwhich lives inreviews.gonowError/Edge Cases
ErrCannotDeleteSubmittedReviewfromreview.goprovides better error reporting for 422 on delete. Consider keeping that sentinel error and the associated check inreviews.go'sDeleteReview.ErrConflictingCommitIDsfromreview.govalidates commit ID consistency across comments. Thereviews.goversion silently takes the first — consider adding the validation back.translateGitHubReviewStatefromreview.gomaps GitHub states to canonical vcs states. Thereviews.goversion passes states through raw. Need to verify which is correct per thevcsinterface contract.Testing Strategy
go build ./...must passgo test ./...must passOpen Questions
ErrConflictingCommitIDsvalidation be ported toreviews.go? The currentreviews.gosilently takes first CommitID. Going with: no, keep it simple — the issue is about fixing the build, not adding features.translateGitHubReviewStatebe ported?reviews.gopasses state through raw. Going with: check what tests expect and align.