Skip to content

fix(js): Render standalone APIKeys in org context when user API keys are disabled#9247

Merged
wobsoriano merged 1 commit into
mainfrom
fix/api-keys-user-disabled-org-context
Jul 24, 2026
Merged

fix(js): Render standalone APIKeys in org context when user API keys are disabled#9247
wobsoriano merged 1 commit into
mainfrom
fix/api-keys-user-disabled-org-context

Conversation

@wobsoriano

@wobsoriano wobsoriano commented Jul 24, 2026

Copy link
Copy Markdown
Member

Description

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@changeset-bot

changeset-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2496aa0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@clerk/clerk-js Patch
@clerk/chrome-extension Patch
@clerk/electron Patch
@clerk/expo Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Jul 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Jul 24, 2026 11:41pm
swingset Ready Ready Preview, Comment Jul 24, 2026 11:41pm

Request Review

@pkg-pr-new

pkg-pr-new Bot commented Jul 24, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@9247

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@9247

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@9247

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@9247

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@9247

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@9247

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@9247

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@9247

@clerk/expo-google-signin

npm i https://pkg.pr.new/@clerk/expo-google-signin@9247

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@9247

@clerk/express

npm i https://pkg.pr.new/@clerk/express@9247

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@9247

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@9247

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@9247

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@9247

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@9247

@clerk/react

npm i https://pkg.pr.new/@clerk/react@9247

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@9247

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@9247

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@9247

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@9247

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@9247

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@9247

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@9247

commit: 2496aa0

@github-actions

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-07-24T23:42:55.847Z

Summary

Metric Count
Packages analyzed 19
Packages with changes 0
🔴 Breaking changes 0
🟡 Non-breaking changes 0
🟢 Additions 0

No API Changes Detected

All packages have stable APIs with no detected changes.


Report generated by Break Check

Last ran on 2496aa0.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

mountAPIKeys now ignores the user API key disabled setting when an organization is active, allowing the standalone <APIKeys /> component to render in organization context. A new Playwright test verifies rendering with user API keys disabled and confirms API key requests use the organization ID as the subject. A changeset records a patch release for @clerk/clerk-js.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description is mostly a generic PR template and does not describe the actual changes made. Replace the template text with a brief summary of the fix, key implementation details, and how to test it.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main fix: APIKeys now render in org context when user API keys are disabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@integration/tests/api-keys-component.test.ts`:
- Around line 391-428: Add focused unit tests for the changed logic in Clerk’s
organization API-key handling, covering both organization-active and
no-organization contexts. Verify the disabled-feature behavior for each branch,
including the expected error or no-op outcome, while retaining this Playwright
test for validating the request subject contract.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: d39e0a58-275a-42e6-bacc-019f192d8cc9

📥 Commits

Reviewing files that changed from the base of the PR and between 74965eb and 2496aa0.

📒 Files selected for processing (3)
  • .changeset/api-keys-org-context-user-disabled.md
  • integration/tests/api-keys-component.test.ts
  • packages/clerk-js/src/core/clerk.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • clerk/clerk_go (manual)
  • clerk/dashboard (manual)
  • clerk/accounts (manual)
  • clerk/backoffice (manual)
  • clerk/clerk (manual)
  • clerk/clerk-docs (manual)
  • clerk/cloudflare-workers (manual)
  • clerk/clerk-ios (auto-detected)
  • clerk/cli (auto-detected)
  • clerk/clerk-android (auto-detected)

Comment on lines +391 to +428
test('standalone API keys component renders in org context when user API keys are disabled', async ({
page,
context,
}) => {
const u = createTestUtils({ app, page, context });

await u.po.signIn.goTo();
await u.po.signIn.waitForMounted();
await u.po.signIn.signInWithEmailAndInstantPassword({ email: fakeAdmin.email, password: fakeAdmin.password });
await u.po.expect.toBeSignedIn();

await u.po.organizationSwitcher.goTo();
await u.po.organizationSwitcher.waitForMounted();
await u.po.organizationSwitcher.waitForAnOrganizationToSelected();

await mockAPIKeysEnvironmentSettings(u.page, { user_api_keys_enabled: false });

let capturedSubject: string | null = null;
const apiKeyRequestPromise = u.page.waitForRequest(request => {
if (request.url().includes('api_keys')) {
const url = new URL(request.url());
capturedSubject = url.searchParams.get('subject');
return true;
}
return false;
});

await u.po.page.goToRelative('/api-keys');
await u.po.apiKeys.waitForMounted();
await expect(u.page.locator('.cl-apiKeys-root')).toBeVisible();

// Org API keys are listed, so the subject must be the organization
await apiKeyRequestPromise;
expect(capturedSubject).toBe(fakeOrganization.organization.id);

await u.page.unrouteAll();
});

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.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add focused unit coverage for both guard branches.

This Playwright test covers the happy path, but the changed logic in packages/clerk-js/src/core/clerk.ts also needs unit coverage for organization-active versus no-organization contexts, including the disabled-feature error/no-op behavior. Retain this integration test for the request-subject contract.

As per coding guidelines, unit tests are required for all new functionality and must cover error handling and edge cases.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@integration/tests/api-keys-component.test.ts` around lines 391 - 428, Add
focused unit tests for the changed logic in Clerk’s organization API-key
handling, covering both organization-active and no-organization contexts. Verify
the disabled-feature behavior for each branch, including the expected error or
no-op outcome, while retaining this Playwright test for validating the request
subject contract.

Source: Coding guidelines

@wobsoriano
wobsoriano merged commit 34d18fa into main Jul 24, 2026
56 of 63 checks passed
@wobsoriano
wobsoriano deleted the fix/api-keys-user-disabled-org-context branch July 24, 2026 23:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants