Skip to content

Offchain votes choices#1803

Merged
pikonha merged 5 commits intodevfrom
fix/offchain-votes-choices
Apr 6, 2026
Merged

Offchain votes choices#1803
pikonha merged 5 commits intodevfrom
fix/offchain-votes-choices

Conversation

@pikonha
Copy link
Copy Markdown
Member

@pikonha pikonha commented Apr 6, 2026

No description provided.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
anticapture Ready Ready Preview, Comment Apr 6, 2026 5:54pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
anticapture-storybook Skipped Skipped Apr 6, 2026 5:54pm

Request Review

@claude
Copy link
Copy Markdown

claude bot commented Apr 6, 2026

Claude encountered an error —— View job


I'll analyze this and get back to you.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d97a8ac572

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

.int()
.transform((val) => [val]),
z.array(z.number().int()),
z.record(z.string(), z.number()).transform((val) => Object.keys(val)),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Convert object vote choices to integers

When Snapshot stores a vote choice as an object (e.g. approval/weighted formats like { "1": 1 }), this branch returns Object.keys(val), which is always a string[]. That violates this endpoint’s declared choice: [Int]! contract and changes runtime payloads from numeric choices to strings for exactly the inputs this commit is trying to support, so consumers that rely on integer arrays will receive the wrong type.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a824095342

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

.transform((val) => [val]),
z.array(z.number().int()),
.transform((val) => [val.toString()]),
z.array(z.string()),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Accept numeric-array vote choices

This schema now only accepts z.array(z.string()) for array-form choices, but Snapshot approval/ranked-choice votes are commonly stored as numeric arrays (e.g. [1, 2]). Those rows will fail OffchainVotesResponseSchema.parse(...) and make /offchain/votes and /offchain/proposals/{id}/votes return 500 whenever such votes are present. Keep supporting numeric arrays (or transform them) to preserve compatibility with existing offchain vote data.

Useful? React with 👍 / 👎.

z.array(z.number().int()),
.transform((val) => [val.toString()]),
z.array(z.string()),
z.record(z.string(), z.number()).transform((val) => Object.keys(val)),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Filter zero-weight entries from object choices

Mapping object-form choices with Object.keys(val) treats every key as selected, even when its weight is 0; this produces incorrect displayed choices for weighted/quadratic votes when the stored payload includes zero-value options. Because weighted vote payloads can include all choice keys with zero defaults, this branch should filter by positive weight before extracting keys to avoid misreporting voter intent.

Useful? React with 👍 / 👎.

@pikonha pikonha merged commit c3521a2 into dev Apr 6, 2026
9 checks passed
@pikonha pikonha deleted the fix/offchain-votes-choices branch April 6, 2026 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant