Skip to content

feat: add scorecards exemptions list command (ISP-1898) - #253

Merged
tonytino merged 1 commit into
mainfrom
auto/isp-1898-exemptions-list
Nov 17, 2026
Merged

tonytino merged 1 commit into
mainfrom
auto/isp-1898-exemptions-list

Conversation

@mmaikel

@mmaikel mmaikel commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Linear: ISP-1898

Why

cortex scorecards exemptions can request, approve, deny and revoke exemptions, but it can't list them. Tealium asked for this. GET /api/v1/scorecards/exemptions was added to the public API in October (CD-594), but the CLI was never updated to use it. For now customers have to call cortex rest get -e api/v1/scorecards/exemptions directly.

What changed

New command cortex scorecards exemptions list in cortexapps_cli/commands/scorecards_commands/exemptions.py. It is built the same way as scorecards list:

Flag API param
--scorecard-tag, -s scorecardTag
--entity-tag, -e entityTag
--rule-id, -ri ruleIdentifier (the API requires --scorecard-tag with it)
--status, -st status: one of PENDING, APPROVED, REJECTED, REVOKED, EXPIRED
--requester-email, -re requesterEmail
--approver-email, -ae approverEmail
--only-active, -a onlyActive=true

It also has the standard list options. Without --page it fetches every page (client.fetch). --page/--page-size return a single page. --table/--csv use these default columns: ID, Scorecard, Rule, Entity, Status, Requester, EndDate. Filters that aren't set are not sent. Validation (rule without scorecard, EXPIRED with --only-active) is left to the API, the same as in the rest of the CLI. For example, the API's 400 message is printed as is. The other four exemption commands are not changed.

Screenshots

image

Tests

New file: tests/test_scorecards_exemptions_list.py. It has 9 tests that mock the API with responses. The exemption tests in test_scorecards.py explain why a live test isn't practical: exemptions can't be put into a known state on the shared test tenants. The tests cover:

  • list appears in the group's help
  • fetching every page
  • each filter maps to its query param (long and short flags)
  • unset filters are not sent
  • an invalid --status is rejected
  • --page makes a single request
  • the default table columns
  • the Requester cell when an API key made the request

8 of the 9 tests fail on main because the command doesn't exist. The status test passes on main too, because any unknown command exits non-zero. All 9 pass on this branch.

I didn't run the command against a live tenant (no API key here). I checked param names and the response shape (exemptions list plus total/page/totalPages) against PublicScorecardRuleExemptionsController.listRuleExemptions in brain-backend.

Size: production +70/−0, tests +136/−0.

Independent review: approve, confidence 90, all acceptance criteria met, no blocking issues. It suggested some optional follow-ups:

  • --status could ignore case.
  • The -a help could mention that it can't be combined with EXPIRED.
  • Tests could cover --csv, -C, -F, -S and --no-headers. These work through the shared output helper and were checked by hand, but no test covers them.

Follow-ups (not in this PR)

The simplify review found two problems in CortexClient.fetch() that affect every list command, so they belong in their own PR:

  • It hard-codes pageSize=250, so --page-size does nothing without --page.
  • A fetch-all past the API's 100,000-result offset limit fails, and the pages it already fetched are lost.

Decisions for reviewer

  • Short flags. -s, -e and -ri reuse what the sibling commands use. -st, -re, -ae and -a are new. The alternative is long flags only for these, which breaks the "long and short" rule in STYLE.md.
  • --entity-tag instead of --tag-or-id/-t. The other exemption commands accept --tag-or-id, but the list endpoint's entityTag only accepts a tag, so the flag says so. The alternative is to use -t for consistency and document that it takes a tag only.
  • Requester column. It shows requestedBy.email. When an API key made the request, the actor has apiKeyLast4 instead and the cell is blank, because a column can only read one field. Approver (exemptionStatus.handledBy.email) is left out: it's empty while an exemption is pending, and it really means whoever handled it, including people who rejected or revoked. On an 80-column terminal rich truncates the wider cells (Rich is the library that draws the tables, and every CLI table works this way). The alternative is to leave Requester out and let people add it with -C.
  • Version bump. The commit is feat:, so merging gives a minor release.

Opened by Hermes ISP autopilot (owner-directed). Needs human review before it is ready.

Adds `cortex scorecards exemptions list`, backed by GET /api/v1/scorecards/exemptions, with the endpoint's filters (scorecard, entity, rule, status, requester, approver, onlyActive) and the standard list options.
@tonytino
tonytino merged commit 381ee9d into main Nov 17, 2026
3 checks passed
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.

3 participants