different-ai/openwork · error · Error

Failed to revoke access (${response.status}).

Error message

Failed to revoke access (${response.status}).

What it means

Thrown by useRevokeMarketplaceAccess in marketplace-data.tsx when DELETE /v1/marketplaces/{marketplaceId}/access/{grantId} (15s timeout) returns neither 204 nor ok. Like the grant path, the error is built by getRequestError (den-flow.ts:527): ReauthRequiredError on 403 {error:'reauth'}, else the server `error` message or fallback "Failed to revoke access (<status>).".

Source

Thrown at ee/apps/den-web/app/(den)/dashboard/_components/marketplace-data.tsx:324

      queryClient.invalidateQueries({ queryKey: marketplaceQueryKeys.resolved(marketplaceId) });
    },
  });
}

export function useRevokeMarketplaceAccess() {
  const queryClient = useQueryClient();
  const { runReauthableAction } = useOrgDashboard();

  return useMutation({
    mutationFn: async (input: { marketplaceId: string; grantId: string }) => {
      await runReauthableAction("revoke-marketplace-access", async () => {
      const { response, payload } = await requestJson(
        `/v1/marketplaces/${encodeURIComponent(input.marketplaceId)}/access/${encodeURIComponent(input.grantId)}`,
        { method: "DELETE" },
        15000,
      );
      if (response.status !== 204 && !response.ok) {
        throw getRequestError(payload, response, `Failed to revoke access (${response.status}).`);
      }
      });
      return input.marketplaceId;
    },
    onSuccess: (marketplaceId) => {
      queryClient.invalidateQueries({ queryKey: marketplaceQueryKeys.access(marketplaceId) });
      queryClient.invalidateQueries({ queryKey: marketplaceQueryKeys.resolved(marketplaceId) });
    },
  });
}

export type ConfigurePluginMcpConnectionInput = {
  pluginId: string;
  configObjectId: string;
  serverName: string;
  authType: ExternalMcpAuthType;
  credentialMode: ExternalMcpCredentialMode;
  apiKey?: string;

View on GitHub (pinned to 2b7df46e8a)

Solutions

  1. On 404, treat as already revoked: invalidate marketplaceQueryKeys.access(marketplaceId) and remove the row locally.
  2. For 403 reauth responses, detect isReauthRequiredError(error) and start the sign-in flow before retrying.
  3. If the server blocks self-revocation, have another admin perform the revoke.
  4. On 5xx/timeout, retry the idempotent DELETE once.

Example fix

// before
if (response.status !== 204 && !response.ok) {
  throw getRequestError(payload, response, `Failed to revoke access (${response.status}).`);
}
// after
if (response.status !== 204 && !response.ok) {
  if (response.status === 404) return input.marketplaceId; // already revoked
  throw getRequestError(payload, response, `Failed to revoke access (${response.status}).`);
}
Defensive patterns

Strategy: try-catch

Validate before calling

// before revoking
if (!grantId) throw new Error("grantId is required.");
if (grant.granteeId === currentUserId && !allowSelfRevoke) {
  throw new Error("Ask another admin to revoke your access.");
}

Type guard

function isReauthError(e: unknown): e is ReauthRequiredError {
  return e instanceof ReauthRequiredError;
}

Try / catch

try {
  await revokeMutation.mutateAsync({ marketplaceId, grantId });
} catch (error) {
  if (isReauthError(error)) { startReauth(); return; }
  if (/\(404\)/.test(error.message)) { await queryClient.invalidateQueries(marketplaceQueryKeys.access(marketplaceId)); return; }
  showToast(error.message);
}

Prevention

When it happens

Trigger: DELETE returns non-ok: 401/403 (caller lacks owner/admin rights or session expired), 404 (grant id already revoked or marketplace removed), 409/422 (grant is the caller's own access or tied to active entitlements), 5xx, or the 15s timeout.

Common situations: Two admins revoking the same grant simultaneously so the second gets 404; revoking your own access which the server forbids; stale grant list after the marketplace was deleted; expired session in a long-open dashboard.

Related errors


AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01). Data as JSON: /api/errors/f4c61144f8cfd6c7. Report an issue: GitHub.