Skip to content

GET /requests?approver=me hides a request the caller could approve (uses remaining(), not could-count) #790

Backlog

Description

@ephico2real2

Found by reviewer 2 (Fable) on PR #785, 2026-12-01 (reviewer 2's report section 5, finding 4). Pre-existing.

approver=me hides a request that the caller can approve (Low)

Parent: story #18. routers/requests.py:80 keeps a request when the caller is in a group of ledger.remaining().
:approve accepts a wider set: a person whose approval fills one more seat after an earlier approver of two groups moves
(ApprovalLedger._eligible). Proof: the ledger of
test_who_may_reject_is_who_may_approve_and_the_group_is_one_still_open; bob approves, and
any(token_group(r["group"]) in bob.groups for r in ledger.remaining()) is false.

# core/approvals.py, in ApprovalLedger
    def could_count(self, groups: frozenset[str]) -> bool:
        """Whether a person of these groups would fill one more seat now: the last check of _eligible, for a list."""
        return len(self._assign(self.entries + [{"groups": frozenset(groups)}])) > len(self._assign(self.entries))

# routers/requests.py
def _can_still_approve(repo: RequestRepo, row, who: Identity) -> bool:
    ledger = repo.ledger(row)
    return bool(ledger) and ledger.could_count(who.groups)
# tests/core/test_approvals.py
def test_the_approver_list_keeps_a_request_that_the_person_can_approve(rules):
    req = rules.decide(facts(action="update", quotaIncreasePct=150))
    prod, platform = req.token_group("approver-prod"), req.token_group("approver-platform")
    led = ApprovalLedger(req, requester_sub="sub-ola")
    led.approve(person("amy", groups={prod, platform}, **APPROVER))
    assert not any(req.token_group(r["group"]) == prod for r in led.remaining())      # today's list rule hides it from bob
    assert led.could_count(frozenset({prod})) and led.could_count(frozenset({platform}))
    assert not led.could_count(frozenset({"/cmapi/app-cmapi-rbac-approver-qa"}))

Run in a scratch copy of the final tree, tests/core/test_approvals.py: before the method, 1 failed (ApprovalLedger
has no could_count) and 40 passed; with it, 41 passed. The change of _can_still_approve itself was not run: it needs a
service test with a two-group request, which the issue's fix adds.

Severity: Low. The Approvals tab hides a request the caller could approve; no wrong decision.

Activity

  1. added
    bug
    sev:low
    Backlog
    on Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Backlogbugsev:low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions