Skip to content

Fix pollbot invalid inputs - #355

Open
michalz-zoom wants to merge 1 commit into
masterfrom
dev/michal/fix-bad-votes
Open

Fix pollbot invalid inputs#355
michalz-zoom wants to merge 1 commit into
masterfrom
dev/michal/fix-bad-votes

Conversation

@michalz-zoom

Copy link
Copy Markdown

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens pollbot’s vote handling by rejecting malformed/invalid vote payloads and out-of-range choices before writing to the database or updating poll results.

Changes:

  • Update NewVoteFromEncoded to return (Vote, error) and properly handle decode/msgpack failures plus missing poll IDs.
  • In the HTTP vote handler, reject invalid vote payloads and enforce Choice bounds based on the poll’s numChoices before casting the vote.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pollbot/pollbot/vote.go Adds error-returning decode path and validates required fields when decoding votes.
pollbot/pollbot/http.go Validates decoded vote payloads and enforces choice range before persisting and updating tallies.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pollbot/pollbot/http.go
return
}
if vote.Choice < 1 || vote.Choice > numChoices {
h.Debug("vote choice %d out of range for poll %s", vote.Choice, vote.ID)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants