Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

fix(electoral-log-console): check only the chosen election's label (meta#15631) (ovcs) - #4708

Merged
Findeton merged 9 commits into
ovcsfrom
fix/rc51-tenant-electoral-log
Dec 3, 2026
Merged

Findeton merged 9 commits into
ovcsfrom
fix/rc51-tenant-electoral-log

Conversation

@Findeton

@Findeton Findeton commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Fixes sequentech/meta#15631 (ovcs). Draft: not merged or deployed.

Problem

On rc.48, the tenant Electoral Log console (Tables tab) answered 403 "Election outside the user's permission labels" with No columns, even when the admin filtered by an election their labels reach. event_board always checked every election of the event (authorize_election_permission_labels(.., None)).

Change

  • Page with an Election filter: checks only that election's label, using authorize_event_election_permission_labels, the same check the election-scoped export uses since OVCS rc.49: election-scoped log export checks only its election; name 403 refusals (meta#15614) #4677. The election must belong to the event, otherwise 400. The store already reads only that election's rows.
  • Record: the electoral_log_console_record action gets an optional election_id. When it is given, the label check above applies, and a record of another election answers 404. The admin portal passes the page's applied election.
  • No election (event-wide, includes entries of no election) and SQL queries: unchanged. Labels must still reach every election. The page/record 403 names each election and label the caller can't reach and adds "Choose an election to read its entries".
  • Super-admin reading another tenant: unchanged (labels only name the caller's own tenant's elections).
  • Grid: when a page fails, the grid keeps the table's columns instead of showing "No columns".
  • The first commit pins that the tenant log route (/electoral-log) refuses another tenant's super admin whether the event id is absent, null, empty or blank. That isolation already held, so it is a regression test only.

No authorization is weakened: every path still checks the tenant permission, and an event-wide read still needs every label.

Tests (synthetic data only)

  • harvest DB route tests: the_console_answers_admins_whose_labels_allow_the_chosen_election and the_console_asks_to_choose_an_election_the_labels_reach. They cover the north-only admin on all 4 tables, a refused south election, the record check, a non-event or non-UUID election → 400, and the 403 text.
  • harvest unit test: requests_read_one_election_only_when_they_name_one.
  • admin-portal: pageColumns unit test. Stories: ReadFails now asserts the headers and drops its now-obsolete aria-required-children expected failure. FilterTheRecords asserts that the record request carries electionId.
  • gql.ts, graphql.ts and both schema.json files were updated by hand for the new optional argument, because codegen needs a live Hasura.

Validation not run locally

The host has 22 GiB free (< 25 GiB policy), and there are no node_modules, cargo build or rustfmt runs in this worktree. So I did not run: cargo check/cargo test/rustfmt for harvest, jest, tsc, prettier, Storybook, or Hasura metadata lint (the pre-push hooks skipped them too). CI is the first real compile and test run.

Demo verification outstanding: on the demo, as an admin whose labels reach only some elections, check the Electoral Log console with and without an Election filter, and open a record.

🤖 Generated with Claude Code

…31) (ovcs)

Pin that the tenant log route refuses a super admin of another tenant,
whether the event id is absent, null, empty or blank.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review: 2

  • release/10.0
  • feat/meta-12767/.*

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

…#15631) (ovcs)

The console page and record always required permission labels reaching
every election of the event, so an admin whose labels reach the election
they filter by still got "Election outside the user's permission labels"
and an empty grid with "No columns".

- A page filtered by an election checks only that election's label; the
  election must be one of the event (400 otherwise). The store already
  reads only that election's rows.
- A record opened from such a page names the election (new optional
  election_id on the Hasura action) and must be one of it (404 otherwise).
- Without an election (entries of no election included) and for queries,
  labels must still reach every election; the 403 names each election and
  label out of reach and asks to choose an election.
- Cross-tenant super-admin reads are unchanged.
- The grid keeps the table's columns when a page fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.2
Preview removed because the pull request was closed.
2026-12-03 23:45 UTC

Findeton and others added 7 commits December 3, 2026 18:04
…a#15631)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… (meta#15631)

The story GraphQL boundary validates operations against the admin portal's
own introspection file, which still lacked the new optional election_id
argument, so OpenARecord failed with 'Invalid operation
ElectoralLogConsoleRecord'.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… of the event (meta#15631)

A super-admin reading another tenant's event skips the label check, but
the selected election is now still validated against the event in the
target tenant, so an invalid selection is a 400 as documented.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ta#15631)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eta#15631)

A page filtered by one election returned estimated_rows, the table's rows
for the whole event before filters, so it counted other elections' rows.
Harvest now omits it for election-scoped pages (event-wide pages keep it);
the admin portal hides the count footer when it is absent. Rows, cursor,
personal-data redaction and label gates are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Findeton
Findeton marked this pull request as ready for review December 3, 2026 23:21
@Findeton
Findeton merged commit 1add59b into ovcs Dec 3, 2026
36 of 38 checks passed
@Findeton
Findeton deleted the fix/rc51-tenant-electoral-log branch December 3, 2026 23:22
edulix added a commit that referenced this pull request Dec 4, 2026
… TEST elections included (meta#15631) (ovcs) (#4721)

Parent issue: sequentech/meta#15631 (rc.49
tracker sequentech/meta#15576)

## Context
On rc.48, the tenant **Electoral Log** console answered 403 "Election
outside the user's permission labels" and showed "No columns" when the
Admin left the Election filter empty. The cause was
`electoral_log_console.rs` `event_board`, which always called
`authorize_election_permission_labels(.., None)`. That check requires
the caller's labels to reach every election of the event, even when the
page is filtered by one election. On ovcs-server the admin holds
BANGKOK, CANBERRA, HONGKONG and MELBOURNE, but event 2ff5dec8 has four
TEST elections labelled `<LABEL>-TEST`, so every read was refused. #4677
did not cause it: the console code was unchanged from rc.48.

**#4708, already merged on ovcs, fixes this.**
- With an Election filter, only that election's label is checked.
- A record opened from that page is checked the same way.
- Without a filter (the event-wide view), the page still needs every
label. The 403 names each election it cannot reach, with its label, and
says "Choose an election".
- The grid keeps the table's columns when a read fails.

#4680 makes TEST elections carry their Post's label, so an admin holding
every Post's label can now browse the whole event.

## This PR: a regression test only

`an_admin_of_every_post_browses_the_whole_event_with_its_test_elections`
(harvest DB route test) rebuilds the rc.48 event's shape: an official
election and a TEST twin per Post (`annotations.test_copy_of`, the same
label, on the Post's area), with ballots and a record.
- An admin labelled with every Post reads records, ballots, voters and
the queue event-wide, with no election chosen.
- An admin of one Post gets a 403 event-wide. The 403 names the other
Post's official and TEST elections, never their own, and asks to choose
an election. That admin then reads each of their own Post's elections
(official and TEST) alone, and is refused the other Post's TEST
election.

## Tests run (arm64, docker: `step-backend-e2e-cargo-packages:local`,
postgres:18)
- `cargo test -p harvest --lib -- electoral_log_console
permission_label_tests`: 26 passed, 0 failed. This covers the new test
and #4708's route tests, which its PR could not run locally.
- admin-portal `jest src/services/ElectoralLogConsole.test.ts`: 9 passed
(#4708's `pageColumns` test).
- `rustfmt` with the harvest config on the changed file.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant