Skip to content

fix: update access commands (list, update, add) to Utilize Permission Chain Directly. - #3856

Open
hiimtaylorjones wants to merge 2 commits into
mainfrom
fix/access-team-app-permissions-column
Open

fix: update access commands (list, update, add) to Utilize Permission Chain Directly.#3856
hiimtaylorjones wants to merge 2 commits into
mainfrom
fix/access-team-app-permissions-column

Conversation

@hiimtaylorjones

@hiimtaylorjones hiimtaylorjones commented Aug 6, 2026

Copy link
Copy Markdown

What's Changing

When listing the permissions that an app directly has, I want to switch out the isTeamApp check to directly tap into the collaborators permission array. This change will allow us to leverage some future API updates around more granular permission controls for apps.

I've also made similar changes to the access:add and access:update commands. They also were utilizing this team check.

Tests Suites Changes

Adds unit tests for the two previously-broken cases alongside the existing ones:

  • personal app → no permissions column (existing)
  • team app → permissions column shown (existing)
  • team service-account-owned app → no permissions column (new)
  • team app with null/absent owner → permissions column shown (new)

All test/unit/commands/access/*.unit.test.ts pass (13 passing).

Verification

Ran this against a scenario I'd been working with in staging. Details will be provided in thread outside of this.

`heroku access` rendered a permissions column for some team apps but not
others because the CLI re-derived "is this a team app?" from the owner
email string (`/@herokumanager\.com$/`) instead of reading what the
Platform API actually sent.

The API only serializes each collaborator's `permissions` array for
genuine team apps (App#team?). The CLI's email regex diverges from that
in two cases:

1. Team service accounts — `foo+service@herokumanager.com` matches the
   CLI regex (column shown) but the API's `team_email?` excludes
   `+service@` (no permissions sent). The CLI's own row filter already
   rejects `herokumanager.com` collaborators, so it was internally
   inconsistent too.
2. Missing/null owner in the payload — `app.owner?.email` → undefined →
   column hidden, even when the API included permission data for a real
   team app.

Drive `showPermissions` off the presence of `permissions` in the
collaborators response — the authoritative source — so the column tracks
exactly what the API sent. `buildTableColumns` and the per-row mapping
already gate on `showPermissions`, so no other changes are needed.
`printAccess` no longer needs the `app` argument.

Adds unit tests covering a team service-account-owned app and a team app
with a null/absent owner, alongside the existing personal- and team-app
cases.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@hiimtaylorjones
hiimtaylorjones marked this pull request as ready for review August 7, 2026 00:29
@hiimtaylorjones
hiimtaylorjones requested a review from a team as a code owner August 7, 2026 00:29
…ands

Extends the previous access-list fix to `access:add`, `access:update`, and
the members lookup in `access` (index). All three re-derived "is this a team
app?" from the owner email regex (`isTeamApp`), which diverges from the
Platform API's own definition (`App#team?`, i.e. `!!team`) in the same two
cases:

- `access:update` refused to update a genuine team app when `owner` was
  absent from the payload (`isTeamApp(undefined)` → false → hard error),
  even though the API would accept the PATCH.
- `access:add` skipped the team-features lookup for a null-owner team app,
  silently dropping `--permissions`; and for other herokumanager.com-shaped
  owners it scraped the team name from the email string rather than using
  the real team name.

Key detection off the authoritative `team` field the API sends, and use
`team.name` for the `/teams/<name>/features` and `/teams/<name>/members`
lookups (falling back to the email-derived name only if `team.name` is
absent). This makes the CLI agree with the API by construction and removes
the now-unused `isTeamApp` imports from these commands. `isTeamApp` remains
in team-utils for `apps:transfer`.

Also makes the `teamApp()` test stub faithful to a real team-app payload
(it now includes a `team` object) and adds `teamAppWithoutOwner()` to cover
the null-owner case in the add and update suites.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@hiimtaylorjones hiimtaylorjones changed the title fix: key access permissions column off API response, not owner email fix: detect team apps via the API team field, not the owner-email regex Aug 7, 2026
@hiimtaylorjones hiimtaylorjones changed the title fix: detect team apps via the API team field, not the owner-email regex Update access commands (list, update, add) to Utilize Permission Chain Directly. Aug 7, 2026
@hiimtaylorjones hiimtaylorjones changed the title Update access commands (list, update, add) to Utilize Permission Chain Directly. (fix): Update access commands (list, update, add) to Utilize Permission Chain Directly. Aug 7, 2026
@hiimtaylorjones hiimtaylorjones changed the title (fix): Update access commands (list, update, add) to Utilize Permission Chain Directly. fix: Update access commands (list, update, add) to Utilize Permission Chain Directly. Aug 7, 2026
@hiimtaylorjones hiimtaylorjones changed the title fix: Update access commands (list, update, add) to Utilize Permission Chain Directly. fix: update access commands (list, update, add) to Utilize Permission Chain Directly. Aug 7, 2026

@michaelmalave michaelmalave left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice update.

@michaelmalave michaelmalave left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice update. LGTM!

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.

2 participants