Validate add_comment_to_pending_review required params before dispatch#2719
Open
gustavo-sec wants to merge 1 commit into
Open
Validate add_comment_to_pending_review required params before dispatch#2719gustavo-sec wants to merge 1 commit into
gustavo-sec wants to merge 1 commit into
Conversation
add_comment_to_pending_review decoded its arguments with mapstructure.WeakDecode and never checked the required ones, so an omitted required argument (e.g. owner) was sent to the GraphQL API and surfaced as a confusing downstream error such as "Could not resolve to a Repository with the name '/<repo>'" instead of a clear missing-parameter message. Validate owner, repo, pullNumber, path, body, and subjectType up front (matching how the other pull request tools use RequiredParam/RequiredInt) so a missing required argument is reported as "missing required parameter: <name>".
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 #2718.
add_comment_to_pending_reviewdecoded its arguments withmapstructure.WeakDecodeand never checked the required ones, so an omitted required argument (e.g.owner) was sent to the GraphQL API and surfaced as a confusing downstream error such asCould not resolve to a Repository with the name '/<repo>'instead of a clear missing-parameter message.What changed
Validate
owner,repo,pullNumber,path,body, andsubjectTypeup front (usingRequiredParam/RequiredInt, matching the other pull request tools) so a missing required argument is reported asmissing required parameter: <name>before any API call.Testing
go test ./...— green.golangci-lint run(v2.9.0) — 0 issues.ownerpath.add_comment_to_pending_reviewwithowneromitted now returnsmissing required parameter: ownerinstead of the downstream repository-resolution error.