Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CVRs with rankings > configured Maximum Number of Candidates That Can Be Ranked should throw a halting exception #808

Open
yezr opened this issue Mar 5, 2024 · 5 comments · May be fixed by #819

Comments

@yezr
Copy link
Collaborator

yezr commented Mar 5, 2024

CVR: CSV CVRs - more ranks than configured.csv
Config: undefined_more-rankings-than-configured.json
The CVR above has 4 rankings, but is configured for a maximum of 3.
image

In the Winning Rules tab there is a setting for Maximum Number of Candidates That Can Be Ranked. If any CVR has a ranking that exceeds this limit it should fail validation as a halting exception.

This ticket is following up with the conversation here in #786.

@artoonie
Copy link
Collaborator

This doesn't work naturally for ES&S files, which look like:

Image

In these files, there are columns after the max ranking. "Max ranking" essentially means that "first vote column" + "max ranking" = "last vote column".

Image

Options:

  1. Add an explicit "last vote column" to the configuration GUI
  2. Read the header rows and validate them in some way
  3. Allow ES&S files to have unlimited columns and only read up to the allowed number

I have opted for (3), which has the downside of being excluded from this check entirely. Would appreciate thoughts on that decision.

@yezr
Copy link
Collaborator Author

yezr commented Apr 12, 2024

Is it possible for option 2 to do something like

  • Go to the first column that we would not expect any more rankings in (first vote column + max ranking)
  • Inspect the first row of that column to see if it is a ranking. I think we could use our current logic to parse it but basically it would do that by checking if the text is
    • a configured candidate name or alias
    • 'undervote'
    • whatever is configured in the CVR Tab as the overvote label
    • whatever is configured in the CVR Tab as the skipped rank label
  • If it is determined to be a ranking, throw the exception, if not continue on our merry way

@artoonie
Copy link
Collaborator

Yep! It'll be somewhat brittle though: if we just check the first row, what if that voter undervoted? Or, what if that column is something like "overvote text" or something else "valid" that gets tripped up by this?

I think another option is:

  1. Look at the header for column and try to determine if it includes "First" or "1" or "1st"
  2. If any of those three match, see if the remainder of the columns follow the expected pattern
  3. If they all do, check the maxRanking+1th column and see if it also follows the pattern
  4. If it does, fail

This is a little less brittle, but still has failure cases (e.g. wouldn't support Choice A, Choice B, etc, or "Column One", "Column Two", etc).

@yezr
Copy link
Collaborator Author

yezr commented Apr 17, 2024

Can we piggyback off of the current validation logic in BaseCvrReader.GatherUnknownCandidates() somehow?

I can also try to confirm the format of the column headers with ES&S. If we can be confident in those that would be even easier.

@artoonie
Copy link
Collaborator

I'm pretty sure GatherUnknownCandidates just uses the range FirstColumn to FirstColumn+MaxNumCandidates, so whatever logic we choose here will likely apply to GatherUnknownCandidates too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Review
Development

Successfully merging a pull request may close this issue.

2 participants