Skip to content

fix!: surface account-plane FORBIDDEN and slim the team projects query - #270

Open
nicknisi wants to merge 5 commits into
mainfrom
fix/account-plane-forbidden-and-slim-team-query
Open

nicknisi wants to merge 5 commits into
mainfrom
fix/account-plane-forbidden-and-slim-team-query

Conversation

@nicknisi

@nicknisi nicknisi commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Prompted by agent feedback in #mcp-agent-feedback: workos project list and organization list failed with "The WorkOS account plane could not complete this request." while MCP whoami worked for the same team.

What was wrong

  • The dashboard refuses with HTTP 200 + errors[].extensions.code: FORBIDDEN, but the client only recognized UNAUTHENTICATED. A permission/capability refusal showed up as a generic server failure. Reproduced on my own account: main prints the generic message, this branch prints forbidden.
  • The error copy dropped every server detail, and environment_unresolved blamed "network or server error" for any failure.
  • teamProjectsV2 (used for environment resolution by every env-scoped command, plus project list) selected the full Environment fragment: certificate expiry, custom domains, resource counts. If one of those resolvers fails for any environment, every command breaks for that team.

Changes

  • All-FORBIDDEN errors[] → forbidden (403), same as HTTP 403. The forbidden copy now also mentions team role.
  • Generic graphql_error copy appends the server error code, e.g. (INTERNAL_SERVER_ERROR). Only clean uppercase identifiers are shown; a GRAPHQL_ prefix is stripped and messages are never echoed (the no-graphql-leak gate covers this).
  • environment_unresolved names the account-plane failure instead of always saying network.
  • teamProjectsV2 is sent with only id, name, environments { id name sandbox clientId }, via an override in resolveExecutableDocument. The vendored snapshot is untouched and the operation name is kept, so the spec routing still matches.

Breaking

workos project list --json environments now contain only id, name, sandbox, clientId. Before, it dumped raw backend fields with uncurated enum casing.

Testing

  • bun run typecheck, bun run lint, and oxfmt --check pass
  • src/lib, src/catalog, src/commands: 2607 passed
  • Full suite: the only failures are installer integration timeouts under load, which pass when run alone
  • Live: bun src/bin.ts project list --json against a team without the capability now returns {"error":{"code":"forbidden",...}}

Riker job 365: Fix two review notes

  • Check: (test -x node_modules/.bin/vitest || timeout 300 bun install --frozen-lockfile … passed on 2496021 (run 3)
  • Review: approved (c897a3e..a33ec4f)
  • Open it: riker job 365 · riker watch 365
  • Riker: 0.88.0 (build 750095c)

Verification: Riker's check passed on exactly this code. Head 2496021, 2026-11-23 17:02 UTC.

- Map an all-FORBIDDEN errors[] response (HTTP 200) to the `forbidden`
  error, same as an HTTP 403. It previously read as a generic
  "could not complete this request".
- Append the server's error code to generic account-plane failures, and
  name the real cause in `environment_unresolved` instead of always
  blaming the network.
- Send `teamProjectsV2` with only the fields the CLI reads. The catalog
  version pulled the full Environment fragment, so one failing resolver
  broke environment resolution for every env-scoped command.

BREAKING CHANGE: `workos project list --json` environments now contain
only id, name, sandbox and clientId instead of every raw backend field.
@greptile-apps

greptile-apps Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with no outstanding findings.

Summary

The PR reports account-plane permission refusals as forbidden, shows filtered server error codes, and narrows teamProjectsV2 to the fields the CLI reads.

  • Account-plane refusals and failures now get clearer explanations.
  • Team lookups request only the project and environment fields the CLI uses.

Reviews (3) · Last reviewed commit: "test: detect team projects catalog drift..." · Reviewed by Greptile

Comment thread src/catalog/operation.ts Resolved
@nicknisi
nicknisi requested a review from gjtorikian November 3, 2026 04:04
@craigsmitham

craigsmitham commented Nov 3, 2026 •

Copy link
Copy Markdown

We’re seeing similar symptoms on macOS with CLI v0.23.0 and v0.24.0:

workos environment list --json
# graphql_error: The WorkOS account plane could not complete this request.

workos authkit redirect-uris list --environment-id <environment_id> --json
# environment_unresolved

The second command fails even with an explicit environment ID, across two Staging environments.

Additional checks:

  • CLI auth status reports authenticated with an unexpired token.
  • The target environment opens successfully in the dashboard.
  • A separate REST API connection lookup succeeds with HTTP 200.
  • Doctor’s connectivity, TLS, and host-execution checks pass.
  • No endpoint or proxy overrides are configured.

@gjtorikian gjtorikian 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.

LGTM overall. Two inline notes: one small test to keep the override from drifting under catalog:vendor, one wording nit.

Comment on lines +159 to +160
});
});

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.

DOCUMENT_OVERRIDES.teamProjectsV2 is a second copy of the selection that catalog:vendor never refreshes. If the dashboard renames projectsV2/clientId/sandbox, the snapshot updates but the override keeps sending the old name, and since this query backs every env-scoped command the blast radius is the one this PR is shrinking. This test only compares the override to string literals, so CI wouldn't catch that.

Suggest a subset guard next to it. Passes today; fails with expected [ 'bogusField' ] to deeply equal [] when I inject a stray field into the override. loadManagementCatalog is already imported at the top of this file.

Suggested change
});
});
});
// The override is a second copy of the selection that `catalog:vendor` never
// refreshes: every name it sends must still exist in the vendored document.
it('selects only fields the vendored catalog also selects', () => {
const op = getOperation('teamProjectsV2');
const catalog = loadManagementCatalog(undefined, { includeFeatureFlagged: true });
const vendored = [op.document, ...op.fragmentNames.map((name) => catalog.fragments[name])].join('\n');
const vendoredNames = new Set(vendored.match(/\w+/g));
const drift = (resolveExecutableDocument(op).match(/\w+/g) ?? []).filter((name) => !vendoredNames.has(name));
expect(drift).toEqual([]);
});
});

Comment thread src/lib/environment-target.ts Outdated
Comment on lines +166 to +170
const cause =
error instanceof DashboardGraphqlError ? `: ${dashboardErrorMessage(error)}` : ' (network or server error).';
exitWithError({
code: 'environment_unresolved',
message: `Could not resolve the target WorkOS environment (network or server error). Try again. ${remedies()}`,
message: `Could not resolve the target WorkOS environment${cause} Try again. ${remedies()}`,

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.

nit: for a network_error, dashboardErrorMessage() already ends with "Check your connection and try again.", so this reads "…and try again. Try again. Pass --environment-id…". One option is to move the retry hint into the fallback branch (oxfmt-clean, both spec files still pass). Trade-off: a 5xx / graphql_error then relies on remedies() alone and loses the explicit "Try again." — fine to leave as-is if you'd rather keep that.

Suggested change
const cause =
error instanceof DashboardGraphqlError ? `: ${dashboardErrorMessage(error)}` : ' (network or server error).';
exitWithError({
code: 'environment_unresolved',
message: `Could not resolve the target WorkOS environment (network or server error). Try again. ${remedies()}`,
message: `Could not resolve the target WorkOS environment${cause} Try again. ${remedies()}`,
const cause =
error instanceof DashboardGraphqlError
? `: ${dashboardErrorMessage(error)}`
: ' (network or server error). Try again.';
exitWithError({
code: 'environment_unresolved',
message: `Could not resolve the target WorkOS environment${cause} ${remedies()}`,

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants