rcv
rcv copied to clipboard
CVRs with rankings > configured Maximum Number of Candidates That Can Be Ranked should throw a halting exception
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.
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.
This doesn't work naturally for ES&S files, which look like:
In these files, there are columns after the max ranking. "Max ranking" essentially means that "first vote column" + "max ranking" = "last vote column".
Options:
- Add an explicit "last vote column" to the configuration GUI
- Read the header rows and validate them in some way
- 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.
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
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:
- Look at the header for column and try to determine if it includes "First" or "1" or "1st"
- If any of those three match, see if the remainder of the columns follow the expected pattern
- If they all do, check the
maxRanking+1th column and see if it also follows the pattern - 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).
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.
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