fix(e2e): more robust user deletion - #9375

Merged
dstaley merged 8 commits into
mainfrom
ds.fix/delete-all-match
Aug 11, 2026
Merged

fix(e2e): more robust user deletion#9375
dstaley merged 8 commits into
mainfrom
ds.fix/delete-all-match

Conversation

@dstaley

Copy link
Copy Markdown
Member

Description

This PR updates the logic we use to create fake users to embed a run key, which is a hash of the unique data for a single test run. After integration tests finish, we manually clean up users that were created with the run key in their username, email address, or metadata.

This also includes a fix for deleteIfExists that will delete all matching users rather than just the first. This handles the case were we generate the same matching email/phone number across multiple tests. This shouldn't be as much of an issue now that we're storing the run key in the identifier, but it doesn't hurt!

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-botBot commented Aug 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 417bb3b

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

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

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

vercelBot commented Aug 10, 2026

Copy link
Copy Markdown

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

ProjectDeploymentActionsUpdated (UTC)
clerk-js-sandboxReadyReadyPreviewAug 11, 2026 4:47pm
swingsetReadyReadyPreviewAug 11, 2026 4:47pm

Request Review

@pkg-pr-new

pkg-pr-newBot commented Aug 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/electron

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

@clerk/electron-passkeys

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

@clerk/eslint-plugin

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

@clerk/expo

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

@clerk/expo-google-signin

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/hono

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

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

@clerk/upgrade

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

@clerk/vue

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

commit: 417bb3b

@coderabbitai

coderabbitaiBot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro Plus

Run ID: cfafa388-05ce-4b49-8e5b-595bdd7dc0bd

📥 Commits

Reviewing files that changed from the base of the PR and between a326a24 and ad2f98a.

📒 Files selected for processing (1)
  • integration/cleanup/cleanup.setup.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/cli(auto-detected)
  • clerk/clerk-ios(auto-detected)
  • clerk/clerk-android(auto-detected)
🚧 Files skipped from review as they are similar to previous changes (1)
  • integration/cleanup/cleanup.setup.ts

📝 Walkthrough

Walkthrough

Integration tests now receive a unique run key from CI. Generated users include a derived E2E marker in identifiers and private metadata. Cleanup discovers and deletes users for the active run, verifies that no marked users remain, and reports run-scoped failures. Turbo passes the run key through the environment. Two changeset files were added.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • clerk/javascript#9374: Both PRs modify integration/testUtils/usersService.ts to tag generated fake users with run metadata for scoped cleanup.

Suggested reviewers:maxyinger

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Title check✅ PassedThe title accurately describes the improved E2E user deletion logic, which is a primary part of the changeset.
Description check✅ PassedThe description directly explains run-key-based user cleanup and deletion of all matching users.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.

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

@coderabbitaicoderabbitaiBot 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: 2

🤖 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/testUtils/usersService.ts`:
- Around line 205-207: Update the empty-user branch in the user cleanup flow to
replace the interpolated opts.email and opts.phoneNumber values with a generic
cleanup message, ensuring no supplied user identifier is written to logs while
preserving the early return.
In `@turbo.json`:
- Line 37: Update the Turbo integration task configuration containing
INTEGRATION_TEST_RUN_KEY so CI integration tasks do not reuse cached results:
set cache to false for those tasks, or move INTEGRATION_TEST_RUN_KEY into
globalEnv to include it in the cache key.
🪄 Autofix

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: a309c6ba-20fe-4646-87e4-e7652685a849

📥 Commits

Reviewing files that changed from the base of the PR and between 52ec5cd and d76132e.

📒 Files selected for processing (7)
  • .changeset/fair-llamas-shout.md
  • .changeset/silver-lands-cut.md
  • .github/workflows/ci.yml
  • integration/cleanup/cleanup.setup.ts
  • integration/testUtils/e2eRun.ts
  • integration/testUtils/usersService.ts
  • turbo.json
🔗 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/cli(auto-detected)
  • clerk/clerk-ios(auto-detected)
  • clerk/clerk-android(auto-detected)

Comment on lines +205 to 207
if (ids.size === 0) {
console.log(`User "${opts.email || opts.phoneNumber}" does not exist!`);
return;

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.

🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

Do not log the supplied email address or phone number.

Line 206 writes a user identifier to CI logs. Log a generic cleanup message instead.

Proposed fix
- console.log(`User "${opts.email || opts.phoneNumber}" does not exist!`);+ console.log('No user exists for the supplied cleanup criteria.');
📝 Committable suggestion

‼️IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if(ids.size===0){
console.log(`User "${opts.email||opts.phoneNumber}" does not exist!`);
return;
if(ids.size===0){
console.log('No user exists for the supplied cleanup criteria.');
return;
🧰 Tools
🪛 ast-grep (0.45.0)

[warning] 205-205: Avoid logging sensitive data
Context: console.log(User "${opts.email || opts.phoneNumber}" does not exist!)
Note: [CWE-532] Insertion of Sensitive Information into Log File.

(log-sensitive-data-typescript)

🤖 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/testUtils/usersService.ts` around lines 205 - 207, Update the
empty-user branch in the user cleanup flow to replace the interpolated
opts.email and opts.phoneNumber values with a generic cleanup message, ensuring
no supplied user identifier is written to logs while preserving the early
return.

Sources: Coding guidelines, Linters/SAST tools

Comment threadturbo.json
"globalPassThroughEnv": [
"AWS_SECRET_KEY",
"GITHUB_TOKEN",
"INTEGRATION_TEST_RUN_KEY",

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
# Every integration task must report cache=false.
jq -r ' (.tasks // {}) | to_entries[] | select(.key | test("test:integration")) | "\(.key): cache=\(.value.cache // true)"' turbo.json

Repository: clerk/javascript

Length of output: 1212


🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
printf'%s\n''--- turbo.json ---'
cat -n turbo.json | sed -n '1,90p'printf'%s\n''--- Turbo version and integration scripts ---'
rg -n '"turbo"|test:integration|INTEGRATION_TEST_RUN_KEY' package.json pnpm-lock.yaml packages apps examples .github 2>/dev/null | head -240

Repository: clerk/javascript

Length of output: 7965


🌐 Web query:

Turborepo globalPassThroughEnv cache key behavior passThroughEnv cacheable task

💡 Result:

In Turborepo, both globalPassThroughEnv and passThroughEnv serve to expose environment variables to task runtimes without including them in the task's cache key [1][2][3]. Because these variables are intentionally omitted from the hashing process, changes to their values will not trigger a cache miss, even if the change would logically affect the output of the task [1][4]. The fundamental behaviors for these configurations are: 1. Cache Key Exclusion: Variables listed in either globalPassThroughEnv or passThroughEnv do not contribute to the task hash [2][3]. Consequently, Turborepo may serve a cached result even if the underlying environment variable has changed [1][4]. This is why these keys should only be used for variables that do not affect the build output, such as authentication tokens (e.g., SENTRY_AUTH_TOKEN), CI metadata, or credentials consumed at runtime after the build process [2][4]. 2. Runtime Exposure: By including a variable in either key, you satisfy Turborepo's Strict Environment Mode, ensuring the task has access to that variable at runtime [1][5][3]. If a task attempts to access an environment variable that is not accounted for in env, globalEnv, passThroughEnv, or globalPassThroughEnv while in Strict Mode, the task may fail [1][5]. 3. Scope Differences: - globalPassThroughEnv (or global.passThroughEnv when using the global configuration flag) applies the passthrough behavior to all tasks within the repository [2][6]. - passThroughEnv applies only to the specific task where it is configured [3]. If you need a change in an environment variable to invalidate the cache and trigger a rebuild, you must include that variable in env or globalEnv instead of the passthrough keys [1][3].

Citations:


🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
printf'%s\n''--- integration task definitions ---'
rg -n -C 3 '"[`#/`]?test:integration|test:integration' turbo.json
printf'%s\n''--- CI Turbo arguments and integration invocation ---'
sed -n '400,535p' .github/workflows/ci.yml
sed -n '260,300p' .github/workflows/e2e-staging.yml
printf'%s\n''--- exact task keys parsed from turbo.json ---'
jq -r '(.tasks // {}) | to_entries[] | select(.key | contains("test:integration")) | [.key, (.value.cache // true | tostring)] | `@tsv`' turbo.json

Repository: clerk/javascript

Length of output: 16346


🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
python3 - <<'PY'import jsonfrom pathlib import Pathconfig = json.loads(Path("turbo.json").read_text())tasks = config.get("tasks", {})matches = [(name, task.get("cache", True)) for name, task in tasks.items() if "test:integration" in name]print("matching task count:", len(matches))for name, cache in matches: print(f"{name}: cache={cache}")PY

Repository: clerk/javascript

Length of output: 1236


🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
printf'%s\n''--- all Turbo force/argument settings ---'
rg -n -C 4 'TURBO_(ARGS|FORCE)|pnpm turbo test:integration|pnpm turbo run test:integration' .github/workflows package.json
printf'%s\n''--- CI workflow environment and matrix context ---'
sed -n '1,120p' .github/workflows/ci.yml
sed -n '380,445p' .github/workflows/ci.yml
sed -n '495,535p' .github/workflows/ci.yml
printf'%s\n''--- staging workflow context ---'
sed -n '1,110p' .github/workflows/e2e-staging.yml
sed -n '270,320p' .github/workflows/e2e-staging.yml

Repository: clerk/javascript

Length of output: 30087


Disable caching for CI integration tasks.

The CI integration job does not set TURBO_FORCE, and all 25 integration tasks inherit cache: true. globalPassThroughEnv does not affect the cache key. Set cache: false for these tasks, or move INTEGRATION_TEST_RUN_KEY to globalEnv.

🤖 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 `@turbo.json` at line 37, Update the Turbo integration task configuration
containing INTEGRATION_TEST_RUN_KEY so CI integration tasks do not reuse cached
results: set cache to false for those tasks, or move INTEGRATION_TEST_RUN_KEY
into globalEnv to include it in the cache key.

@wobsorianowobsoriano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Extra changesets but everything looks good!

@dstaley
dstaley merged commit 07344ca into mainAug 11, 2026
49 of 50 checks passed
@dstaley
dstaley deleted the ds.fix/delete-all-match branch August 11, 2026 16:54
Sign up for freeto 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

@dstaley@wobsoriano
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

fix(e2e): more robust user deletion - #9375

Merged
dstaley merged 8 commits into
mainfrom
ds.fix/delete-all-match
Aug 11, 2026
Merged

fix(e2e): more robust user deletion#9375
dstaley merged 8 commits into
mainfrom
ds.fix/delete-all-match

Conversation

@dstaley

Copy link
Copy Markdown
Member

Description

This PR updates the logic we use to create fake users to embed a run key, which is a hash of the unique data for a single test run. After integration tests finish, we manually clean up users that were created with the run key in their username, email address, or metadata.

This also includes a fix for deleteIfExists that will delete all matching users rather than just the first. This handles the case were we generate the same matching email/phone number across multiple tests. This shouldn't be as much of an issue now that we're storing the run key in the identifier, but it doesn't hurt!

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-botBot commented Aug 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 417bb3b

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

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

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

vercelBot commented Aug 10, 2026

Copy link
Copy Markdown

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

ProjectDeploymentActionsUpdated (UTC)
clerk-js-sandboxReadyReadyPreviewAug 11, 2026 4:47pm
swingsetReadyReadyPreviewAug 11, 2026 4:47pm

Request Review

@pkg-pr-new

pkg-pr-newBot commented Aug 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/electron

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

@clerk/electron-passkeys

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

@clerk/eslint-plugin

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

@clerk/expo

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

@clerk/expo-google-signin

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/hono

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

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

@clerk/upgrade

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

@clerk/vue

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

commit: 417bb3b

@coderabbitai

coderabbitaiBot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro Plus

Run ID: cfafa388-05ce-4b49-8e5b-595bdd7dc0bd

📥 Commits

Reviewing files that changed from the base of the PR and between a326a24 and ad2f98a.

📒 Files selected for processing (1)
  • integration/cleanup/cleanup.setup.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/cli(auto-detected)
  • clerk/clerk-ios(auto-detected)
  • clerk/clerk-android(auto-detected)
🚧 Files skipped from review as they are similar to previous changes (1)
  • integration/cleanup/cleanup.setup.ts

📝 Walkthrough

Walkthrough

Integration tests now receive a unique run key from CI. Generated users include a derived E2E marker in identifiers and private metadata. Cleanup discovers and deletes users for the active run, verifies that no marked users remain, and reports run-scoped failures. Turbo passes the run key through the environment. Two changeset files were added.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • clerk/javascript#9374: Both PRs modify integration/testUtils/usersService.ts to tag generated fake users with run metadata for scoped cleanup.

Suggested reviewers:maxyinger

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Title check✅ PassedThe title accurately describes the improved E2E user deletion logic, which is a primary part of the changeset.
Description check✅ PassedThe description directly explains run-key-based user cleanup and deletion of all matching users.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.

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

@coderabbitaicoderabbitaiBot 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: 2

🤖 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/testUtils/usersService.ts`:
- Around line 205-207: Update the empty-user branch in the user cleanup flow to
replace the interpolated opts.email and opts.phoneNumber values with a generic
cleanup message, ensuring no supplied user identifier is written to logs while
preserving the early return.
In `@turbo.json`:
- Line 37: Update the Turbo integration task configuration containing
INTEGRATION_TEST_RUN_KEY so CI integration tasks do not reuse cached results:
set cache to false for those tasks, or move INTEGRATION_TEST_RUN_KEY into
globalEnv to include it in the cache key.
🪄 Autofix

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: a309c6ba-20fe-4646-87e4-e7652685a849

📥 Commits

Reviewing files that changed from the base of the PR and between 52ec5cd and d76132e.

📒 Files selected for processing (7)
  • .changeset/fair-llamas-shout.md
  • .changeset/silver-lands-cut.md
  • .github/workflows/ci.yml
  • integration/cleanup/cleanup.setup.ts
  • integration/testUtils/e2eRun.ts
  • integration/testUtils/usersService.ts
  • turbo.json
🔗 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/cli(auto-detected)
  • clerk/clerk-ios(auto-detected)
  • clerk/clerk-android(auto-detected)

Comment on lines +205 to 207
if (ids.size === 0) {
console.log(`User "${opts.email || opts.phoneNumber}" does not exist!`);
return;

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.

🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

Do not log the supplied email address or phone number.

Line 206 writes a user identifier to CI logs. Log a generic cleanup message instead.

Proposed fix
- console.log(`User "${opts.email || opts.phoneNumber}" does not exist!`);+ console.log('No user exists for the supplied cleanup criteria.');
📝 Committable suggestion

‼️IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if(ids.size===0){
console.log(`User "${opts.email||opts.phoneNumber}" does not exist!`);
return;
if(ids.size===0){
console.log('No user exists for the supplied cleanup criteria.');
return;
🧰 Tools
🪛 ast-grep (0.45.0)

[warning] 205-205: Avoid logging sensitive data
Context: console.log(User "${opts.email || opts.phoneNumber}" does not exist!)
Note: [CWE-532] Insertion of Sensitive Information into Log File.

(log-sensitive-data-typescript)

🤖 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/testUtils/usersService.ts` around lines 205 - 207, Update the
empty-user branch in the user cleanup flow to replace the interpolated
opts.email and opts.phoneNumber values with a generic cleanup message, ensuring
no supplied user identifier is written to logs while preserving the early
return.

Sources: Coding guidelines, Linters/SAST tools

Comment threadturbo.json
"globalPassThroughEnv": [
"AWS_SECRET_KEY",
"GITHUB_TOKEN",
"INTEGRATION_TEST_RUN_KEY",

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
# Every integration task must report cache=false.
jq -r ' (.tasks // {}) | to_entries[] | select(.key | test("test:integration")) | "\(.key): cache=\(.value.cache // true)"' turbo.json

Repository: clerk/javascript

Length of output: 1212


🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
printf'%s\n''--- turbo.json ---'
cat -n turbo.json | sed -n '1,90p'printf'%s\n''--- Turbo version and integration scripts ---'
rg -n '"turbo"|test:integration|INTEGRATION_TEST_RUN_KEY' package.json pnpm-lock.yaml packages apps examples .github 2>/dev/null | head -240

Repository: clerk/javascript

Length of output: 7965


🌐 Web query:

Turborepo globalPassThroughEnv cache key behavior passThroughEnv cacheable task

💡 Result:

In Turborepo, both globalPassThroughEnv and passThroughEnv serve to expose environment variables to task runtimes without including them in the task's cache key [1][2][3]. Because these variables are intentionally omitted from the hashing process, changes to their values will not trigger a cache miss, even if the change would logically affect the output of the task [1][4]. The fundamental behaviors for these configurations are: 1. Cache Key Exclusion: Variables listed in either globalPassThroughEnv or passThroughEnv do not contribute to the task hash [2][3]. Consequently, Turborepo may serve a cached result even if the underlying environment variable has changed [1][4]. This is why these keys should only be used for variables that do not affect the build output, such as authentication tokens (e.g., SENTRY_AUTH_TOKEN), CI metadata, or credentials consumed at runtime after the build process [2][4]. 2. Runtime Exposure: By including a variable in either key, you satisfy Turborepo's Strict Environment Mode, ensuring the task has access to that variable at runtime [1][5][3]. If a task attempts to access an environment variable that is not accounted for in env, globalEnv, passThroughEnv, or globalPassThroughEnv while in Strict Mode, the task may fail [1][5]. 3. Scope Differences: - globalPassThroughEnv (or global.passThroughEnv when using the global configuration flag) applies the passthrough behavior to all tasks within the repository [2][6]. - passThroughEnv applies only to the specific task where it is configured [3]. If you need a change in an environment variable to invalidate the cache and trigger a rebuild, you must include that variable in env or globalEnv instead of the passthrough keys [1][3].

Citations:


🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
printf'%s\n''--- integration task definitions ---'
rg -n -C 3 '"[`#/`]?test:integration|test:integration' turbo.json
printf'%s\n''--- CI Turbo arguments and integration invocation ---'
sed -n '400,535p' .github/workflows/ci.yml
sed -n '260,300p' .github/workflows/e2e-staging.yml
printf'%s\n''--- exact task keys parsed from turbo.json ---'
jq -r '(.tasks // {}) | to_entries[] | select(.key | contains("test:integration")) | [.key, (.value.cache // true | tostring)] | `@tsv`' turbo.json

Repository: clerk/javascript

Length of output: 16346


🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
python3 - <<'PY'import jsonfrom pathlib import Pathconfig = json.loads(Path("turbo.json").read_text())tasks = config.get("tasks", {})matches = [(name, task.get("cache", True)) for name, task in tasks.items() if "test:integration" in name]print("matching task count:", len(matches))for name, cache in matches: print(f"{name}: cache={cache}")PY

Repository: clerk/javascript

Length of output: 1236


🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
printf'%s\n''--- all Turbo force/argument settings ---'
rg -n -C 4 'TURBO_(ARGS|FORCE)|pnpm turbo test:integration|pnpm turbo run test:integration' .github/workflows package.json
printf'%s\n''--- CI workflow environment and matrix context ---'
sed -n '1,120p' .github/workflows/ci.yml
sed -n '380,445p' .github/workflows/ci.yml
sed -n '495,535p' .github/workflows/ci.yml
printf'%s\n''--- staging workflow context ---'
sed -n '1,110p' .github/workflows/e2e-staging.yml
sed -n '270,320p' .github/workflows/e2e-staging.yml

Repository: clerk/javascript

Length of output: 30087


Disable caching for CI integration tasks.

The CI integration job does not set TURBO_FORCE, and all 25 integration tasks inherit cache: true. globalPassThroughEnv does not affect the cache key. Set cache: false for these tasks, or move INTEGRATION_TEST_RUN_KEY to globalEnv.

🤖 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 `@turbo.json` at line 37, Update the Turbo integration task configuration
containing INTEGRATION_TEST_RUN_KEY so CI integration tasks do not reuse cached
results: set cache to false for those tasks, or move INTEGRATION_TEST_RUN_KEY
into globalEnv to include it in the cache key.

@wobsorianowobsoriano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Extra changesets but everything looks good!

@dstaley
dstaley merged commit 07344ca into mainAug 11, 2026
49 of 50 checks passed
@dstaley
dstaley deleted the ds.fix/delete-all-match branch August 11, 2026 16:54
Sign up for freeto 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

@dstaley@wobsoriano
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

fix(e2e): more robust user deletion - #9375

Merged
dstaley merged 8 commits into
mainfrom
ds.fix/delete-all-match
Aug 11, 2026
Merged

fix(e2e): more robust user deletion#9375
dstaley merged 8 commits into
mainfrom
ds.fix/delete-all-match

Conversation

@dstaley

Copy link
Copy Markdown
Member

Description

This PR updates the logic we use to create fake users to embed a run key, which is a hash of the unique data for a single test run. After integration tests finish, we manually clean up users that were created with the run key in their username, email address, or metadata.

This also includes a fix for deleteIfExists that will delete all matching users rather than just the first. This handles the case were we generate the same matching email/phone number across multiple tests. This shouldn't be as much of an issue now that we're storing the run key in the identifier, but it doesn't hurt!

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-botBot commented Aug 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 417bb3b

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

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

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

vercelBot commented Aug 10, 2026

Copy link
Copy Markdown

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

ProjectDeploymentActionsUpdated (UTC)
clerk-js-sandboxReadyReadyPreviewAug 11, 2026 4:47pm
swingsetReadyReadyPreviewAug 11, 2026 4:47pm

Request Review

@pkg-pr-new

pkg-pr-newBot commented Aug 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/electron

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

@clerk/electron-passkeys

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

@clerk/eslint-plugin

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

@clerk/expo

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

@clerk/expo-google-signin

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/hono

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

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

@clerk/upgrade

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

@clerk/vue

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

commit: 417bb3b

@coderabbitai

coderabbitaiBot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro Plus

Run ID: cfafa388-05ce-4b49-8e5b-595bdd7dc0bd

📥 Commits

Reviewing files that changed from the base of the PR and between a326a24 and ad2f98a.

📒 Files selected for processing (1)
  • integration/cleanup/cleanup.setup.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/cli(auto-detected)
  • clerk/clerk-ios(auto-detected)
  • clerk/clerk-android(auto-detected)
🚧 Files skipped from review as they are similar to previous changes (1)
  • integration/cleanup/cleanup.setup.ts

📝 Walkthrough

Walkthrough

Integration tests now receive a unique run key from CI. Generated users include a derived E2E marker in identifiers and private metadata. Cleanup discovers and deletes users for the active run, verifies that no marked users remain, and reports run-scoped failures. Turbo passes the run key through the environment. Two changeset files were added.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • clerk/javascript#9374: Both PRs modify integration/testUtils/usersService.ts to tag generated fake users with run metadata for scoped cleanup.

Suggested reviewers:maxyinger

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Title check✅ PassedThe title accurately describes the improved E2E user deletion logic, which is a primary part of the changeset.
Description check✅ PassedThe description directly explains run-key-based user cleanup and deletion of all matching users.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.

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

@coderabbitaicoderabbitaiBot 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: 2

🤖 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/testUtils/usersService.ts`:
- Around line 205-207: Update the empty-user branch in the user cleanup flow to
replace the interpolated opts.email and opts.phoneNumber values with a generic
cleanup message, ensuring no supplied user identifier is written to logs while
preserving the early return.
In `@turbo.json`:
- Line 37: Update the Turbo integration task configuration containing
INTEGRATION_TEST_RUN_KEY so CI integration tasks do not reuse cached results:
set cache to false for those tasks, or move INTEGRATION_TEST_RUN_KEY into
globalEnv to include it in the cache key.
🪄 Autofix

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: a309c6ba-20fe-4646-87e4-e7652685a849

📥 Commits

Reviewing files that changed from the base of the PR and between 52ec5cd and d76132e.

📒 Files selected for processing (7)
  • .changeset/fair-llamas-shout.md
  • .changeset/silver-lands-cut.md
  • .github/workflows/ci.yml
  • integration/cleanup/cleanup.setup.ts
  • integration/testUtils/e2eRun.ts
  • integration/testUtils/usersService.ts
  • turbo.json
🔗 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/cli(auto-detected)
  • clerk/clerk-ios(auto-detected)
  • clerk/clerk-android(auto-detected)

Comment on lines +205 to 207
if (ids.size === 0) {
console.log(`User "${opts.email || opts.phoneNumber}" does not exist!`);
return;

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.

🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

Do not log the supplied email address or phone number.

Line 206 writes a user identifier to CI logs. Log a generic cleanup message instead.

Proposed fix
- console.log(`User "${opts.email || opts.phoneNumber}" does not exist!`);+ console.log('No user exists for the supplied cleanup criteria.');
📝 Committable suggestion

‼️IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if(ids.size===0){
console.log(`User "${opts.email||opts.phoneNumber}" does not exist!`);
return;
if(ids.size===0){
console.log('No user exists for the supplied cleanup criteria.');
return;
🧰 Tools
🪛 ast-grep (0.45.0)

[warning] 205-205: Avoid logging sensitive data
Context: console.log(User "${opts.email || opts.phoneNumber}" does not exist!)
Note: [CWE-532] Insertion of Sensitive Information into Log File.

(log-sensitive-data-typescript)

🤖 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/testUtils/usersService.ts` around lines 205 - 207, Update the
empty-user branch in the user cleanup flow to replace the interpolated
opts.email and opts.phoneNumber values with a generic cleanup message, ensuring
no supplied user identifier is written to logs while preserving the early
return.

Sources: Coding guidelines, Linters/SAST tools

Comment threadturbo.json
"globalPassThroughEnv": [
"AWS_SECRET_KEY",
"GITHUB_TOKEN",
"INTEGRATION_TEST_RUN_KEY",

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
# Every integration task must report cache=false.
jq -r ' (.tasks // {}) | to_entries[] | select(.key | test("test:integration")) | "\(.key): cache=\(.value.cache // true)"' turbo.json

Repository: clerk/javascript

Length of output: 1212


🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
printf'%s\n''--- turbo.json ---'
cat -n turbo.json | sed -n '1,90p'printf'%s\n''--- Turbo version and integration scripts ---'
rg -n '"turbo"|test:integration|INTEGRATION_TEST_RUN_KEY' package.json pnpm-lock.yaml packages apps examples .github 2>/dev/null | head -240

Repository: clerk/javascript

Length of output: 7965


🌐 Web query:

Turborepo globalPassThroughEnv cache key behavior passThroughEnv cacheable task

💡 Result:

In Turborepo, both globalPassThroughEnv and passThroughEnv serve to expose environment variables to task runtimes without including them in the task's cache key [1][2][3]. Because these variables are intentionally omitted from the hashing process, changes to their values will not trigger a cache miss, even if the change would logically affect the output of the task [1][4]. The fundamental behaviors for these configurations are: 1. Cache Key Exclusion: Variables listed in either globalPassThroughEnv or passThroughEnv do not contribute to the task hash [2][3]. Consequently, Turborepo may serve a cached result even if the underlying environment variable has changed [1][4]. This is why these keys should only be used for variables that do not affect the build output, such as authentication tokens (e.g., SENTRY_AUTH_TOKEN), CI metadata, or credentials consumed at runtime after the build process [2][4]. 2. Runtime Exposure: By including a variable in either key, you satisfy Turborepo's Strict Environment Mode, ensuring the task has access to that variable at runtime [1][5][3]. If a task attempts to access an environment variable that is not accounted for in env, globalEnv, passThroughEnv, or globalPassThroughEnv while in Strict Mode, the task may fail [1][5]. 3. Scope Differences: - globalPassThroughEnv (or global.passThroughEnv when using the global configuration flag) applies the passthrough behavior to all tasks within the repository [2][6]. - passThroughEnv applies only to the specific task where it is configured [3]. If you need a change in an environment variable to invalidate the cache and trigger a rebuild, you must include that variable in env or globalEnv instead of the passthrough keys [1][3].

Citations:


🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
printf'%s\n''--- integration task definitions ---'
rg -n -C 3 '"[`#/`]?test:integration|test:integration' turbo.json
printf'%s\n''--- CI Turbo arguments and integration invocation ---'
sed -n '400,535p' .github/workflows/ci.yml
sed -n '260,300p' .github/workflows/e2e-staging.yml
printf'%s\n''--- exact task keys parsed from turbo.json ---'
jq -r '(.tasks // {}) | to_entries[] | select(.key | contains("test:integration")) | [.key, (.value.cache // true | tostring)] | `@tsv`' turbo.json

Repository: clerk/javascript

Length of output: 16346


🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
python3 - <<'PY'import jsonfrom pathlib import Pathconfig = json.loads(Path("turbo.json").read_text())tasks = config.get("tasks", {})matches = [(name, task.get("cache", True)) for name, task in tasks.items() if "test:integration" in name]print("matching task count:", len(matches))for name, cache in matches: print(f"{name}: cache={cache}")PY

Repository: clerk/javascript

Length of output: 1236


🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
printf'%s\n''--- all Turbo force/argument settings ---'
rg -n -C 4 'TURBO_(ARGS|FORCE)|pnpm turbo test:integration|pnpm turbo run test:integration' .github/workflows package.json
printf'%s\n''--- CI workflow environment and matrix context ---'
sed -n '1,120p' .github/workflows/ci.yml
sed -n '380,445p' .github/workflows/ci.yml
sed -n '495,535p' .github/workflows/ci.yml
printf'%s\n''--- staging workflow context ---'
sed -n '1,110p' .github/workflows/e2e-staging.yml
sed -n '270,320p' .github/workflows/e2e-staging.yml

Repository: clerk/javascript

Length of output: 30087


Disable caching for CI integration tasks.

The CI integration job does not set TURBO_FORCE, and all 25 integration tasks inherit cache: true. globalPassThroughEnv does not affect the cache key. Set cache: false for these tasks, or move INTEGRATION_TEST_RUN_KEY to globalEnv.

🤖 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 `@turbo.json` at line 37, Update the Turbo integration task configuration
containing INTEGRATION_TEST_RUN_KEY so CI integration tasks do not reuse cached
results: set cache to false for those tasks, or move INTEGRATION_TEST_RUN_KEY
into globalEnv to include it in the cache key.

@wobsorianowobsoriano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Extra changesets but everything looks good!

@dstaley
dstaley merged commit 07344ca into mainAug 11, 2026
49 of 50 checks passed
@dstaley
dstaley deleted the ds.fix/delete-all-match branch August 11, 2026 16:54
Sign up for freeto 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

@dstaley@wobsoriano
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

fix(e2e): more robust user deletion - #9375

Merged
dstaley merged 8 commits into
mainfrom
ds.fix/delete-all-match
Aug 11, 2026
Merged

fix(e2e): more robust user deletion#9375
dstaley merged 8 commits into
mainfrom
ds.fix/delete-all-match

Conversation

@dstaley

Copy link
Copy Markdown
Member

Description

This PR updates the logic we use to create fake users to embed a run key, which is a hash of the unique data for a single test run. After integration tests finish, we manually clean up users that were created with the run key in their username, email address, or metadata.

This also includes a fix for deleteIfExists that will delete all matching users rather than just the first. This handles the case were we generate the same matching email/phone number across multiple tests. This shouldn't be as much of an issue now that we're storing the run key in the identifier, but it doesn't hurt!

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-botBot commented Aug 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 417bb3b

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

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

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

vercelBot commented Aug 10, 2026

Copy link
Copy Markdown

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

ProjectDeploymentActionsUpdated (UTC)
clerk-js-sandboxReadyReadyPreviewAug 11, 2026 4:47pm
swingsetReadyReadyPreviewAug 11, 2026 4:47pm

Request Review

@pkg-pr-new

pkg-pr-newBot commented Aug 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/electron

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

@clerk/electron-passkeys

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

@clerk/eslint-plugin

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

@clerk/expo

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

@clerk/expo-google-signin

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/hono

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

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

@clerk/upgrade

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

@clerk/vue

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

commit: 417bb3b

@coderabbitai

coderabbitaiBot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro Plus

Run ID: cfafa388-05ce-4b49-8e5b-595bdd7dc0bd

📥 Commits

Reviewing files that changed from the base of the PR and between a326a24 and ad2f98a.

📒 Files selected for processing (1)
  • integration/cleanup/cleanup.setup.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/cli(auto-detected)
  • clerk/clerk-ios(auto-detected)
  • clerk/clerk-android(auto-detected)
🚧 Files skipped from review as they are similar to previous changes (1)
  • integration/cleanup/cleanup.setup.ts

📝 Walkthrough

Walkthrough

Integration tests now receive a unique run key from CI. Generated users include a derived E2E marker in identifiers and private metadata. Cleanup discovers and deletes users for the active run, verifies that no marked users remain, and reports run-scoped failures. Turbo passes the run key through the environment. Two changeset files were added.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • clerk/javascript#9374: Both PRs modify integration/testUtils/usersService.ts to tag generated fake users with run metadata for scoped cleanup.

Suggested reviewers:maxyinger

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Title check✅ PassedThe title accurately describes the improved E2E user deletion logic, which is a primary part of the changeset.
Description check✅ PassedThe description directly explains run-key-based user cleanup and deletion of all matching users.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.

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

@coderabbitaicoderabbitaiBot 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: 2

🤖 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/testUtils/usersService.ts`:
- Around line 205-207: Update the empty-user branch in the user cleanup flow to
replace the interpolated opts.email and opts.phoneNumber values with a generic
cleanup message, ensuring no supplied user identifier is written to logs while
preserving the early return.
In `@turbo.json`:
- Line 37: Update the Turbo integration task configuration containing
INTEGRATION_TEST_RUN_KEY so CI integration tasks do not reuse cached results:
set cache to false for those tasks, or move INTEGRATION_TEST_RUN_KEY into
globalEnv to include it in the cache key.
🪄 Autofix

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: a309c6ba-20fe-4646-87e4-e7652685a849

📥 Commits

Reviewing files that changed from the base of the PR and between 52ec5cd and d76132e.

📒 Files selected for processing (7)
  • .changeset/fair-llamas-shout.md
  • .changeset/silver-lands-cut.md
  • .github/workflows/ci.yml
  • integration/cleanup/cleanup.setup.ts
  • integration/testUtils/e2eRun.ts
  • integration/testUtils/usersService.ts
  • turbo.json
🔗 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/cli(auto-detected)
  • clerk/clerk-ios(auto-detected)
  • clerk/clerk-android(auto-detected)

Comment on lines +205 to 207
if (ids.size === 0) {
console.log(`User "${opts.email || opts.phoneNumber}" does not exist!`);
return;

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.

🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

Do not log the supplied email address or phone number.

Line 206 writes a user identifier to CI logs. Log a generic cleanup message instead.

Proposed fix
- console.log(`User "${opts.email || opts.phoneNumber}" does not exist!`);+ console.log('No user exists for the supplied cleanup criteria.');
📝 Committable suggestion

‼️IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if(ids.size===0){
console.log(`User "${opts.email||opts.phoneNumber}" does not exist!`);
return;
if(ids.size===0){
console.log('No user exists for the supplied cleanup criteria.');
return;
🧰 Tools
🪛 ast-grep (0.45.0)

[warning] 205-205: Avoid logging sensitive data
Context: console.log(User "${opts.email || opts.phoneNumber}" does not exist!)
Note: [CWE-532] Insertion of Sensitive Information into Log File.

(log-sensitive-data-typescript)

🤖 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/testUtils/usersService.ts` around lines 205 - 207, Update the
empty-user branch in the user cleanup flow to replace the interpolated
opts.email and opts.phoneNumber values with a generic cleanup message, ensuring
no supplied user identifier is written to logs while preserving the early
return.

Sources: Coding guidelines, Linters/SAST tools

Comment threadturbo.json
"globalPassThroughEnv": [
"AWS_SECRET_KEY",
"GITHUB_TOKEN",
"INTEGRATION_TEST_RUN_KEY",

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
# Every integration task must report cache=false.
jq -r ' (.tasks // {}) | to_entries[] | select(.key | test("test:integration")) | "\(.key): cache=\(.value.cache // true)"' turbo.json

Repository: clerk/javascript

Length of output: 1212


🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
printf'%s\n''--- turbo.json ---'
cat -n turbo.json | sed -n '1,90p'printf'%s\n''--- Turbo version and integration scripts ---'
rg -n '"turbo"|test:integration|INTEGRATION_TEST_RUN_KEY' package.json pnpm-lock.yaml packages apps examples .github 2>/dev/null | head -240

Repository: clerk/javascript

Length of output: 7965


🌐 Web query:

Turborepo globalPassThroughEnv cache key behavior passThroughEnv cacheable task

💡 Result:

In Turborepo, both globalPassThroughEnv and passThroughEnv serve to expose environment variables to task runtimes without including them in the task's cache key [1][2][3]. Because these variables are intentionally omitted from the hashing process, changes to their values will not trigger a cache miss, even if the change would logically affect the output of the task [1][4]. The fundamental behaviors for these configurations are: 1. Cache Key Exclusion: Variables listed in either globalPassThroughEnv or passThroughEnv do not contribute to the task hash [2][3]. Consequently, Turborepo may serve a cached result even if the underlying environment variable has changed [1][4]. This is why these keys should only be used for variables that do not affect the build output, such as authentication tokens (e.g., SENTRY_AUTH_TOKEN), CI metadata, or credentials consumed at runtime after the build process [2][4]. 2. Runtime Exposure: By including a variable in either key, you satisfy Turborepo's Strict Environment Mode, ensuring the task has access to that variable at runtime [1][5][3]. If a task attempts to access an environment variable that is not accounted for in env, globalEnv, passThroughEnv, or globalPassThroughEnv while in Strict Mode, the task may fail [1][5]. 3. Scope Differences: - globalPassThroughEnv (or global.passThroughEnv when using the global configuration flag) applies the passthrough behavior to all tasks within the repository [2][6]. - passThroughEnv applies only to the specific task where it is configured [3]. If you need a change in an environment variable to invalidate the cache and trigger a rebuild, you must include that variable in env or globalEnv instead of the passthrough keys [1][3].

Citations:


🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
printf'%s\n''--- integration task definitions ---'
rg -n -C 3 '"[`#/`]?test:integration|test:integration' turbo.json
printf'%s\n''--- CI Turbo arguments and integration invocation ---'
sed -n '400,535p' .github/workflows/ci.yml
sed -n '260,300p' .github/workflows/e2e-staging.yml
printf'%s\n''--- exact task keys parsed from turbo.json ---'
jq -r '(.tasks // {}) | to_entries[] | select(.key | contains("test:integration")) | [.key, (.value.cache // true | tostring)] | `@tsv`' turbo.json

Repository: clerk/javascript

Length of output: 16346


🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
python3 - <<'PY'import jsonfrom pathlib import Pathconfig = json.loads(Path("turbo.json").read_text())tasks = config.get("tasks", {})matches = [(name, task.get("cache", True)) for name, task in tasks.items() if "test:integration" in name]print("matching task count:", len(matches))for name, cache in matches: print(f"{name}: cache={cache}")PY

Repository: clerk/javascript

Length of output: 1236


🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
printf'%s\n''--- all Turbo force/argument settings ---'
rg -n -C 4 'TURBO_(ARGS|FORCE)|pnpm turbo test:integration|pnpm turbo run test:integration' .github/workflows package.json
printf'%s\n''--- CI workflow environment and matrix context ---'
sed -n '1,120p' .github/workflows/ci.yml
sed -n '380,445p' .github/workflows/ci.yml
sed -n '495,535p' .github/workflows/ci.yml
printf'%s\n''--- staging workflow context ---'
sed -n '1,110p' .github/workflows/e2e-staging.yml
sed -n '270,320p' .github/workflows/e2e-staging.yml

Repository: clerk/javascript

Length of output: 30087


Disable caching for CI integration tasks.

The CI integration job does not set TURBO_FORCE, and all 25 integration tasks inherit cache: true. globalPassThroughEnv does not affect the cache key. Set cache: false for these tasks, or move INTEGRATION_TEST_RUN_KEY to globalEnv.

🤖 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 `@turbo.json` at line 37, Update the Turbo integration task configuration
containing INTEGRATION_TEST_RUN_KEY so CI integration tasks do not reuse cached
results: set cache to false for those tasks, or move INTEGRATION_TEST_RUN_KEY
into globalEnv to include it in the cache key.

@wobsorianowobsoriano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Extra changesets but everything looks good!

@dstaley
dstaley merged commit 07344ca into mainAug 11, 2026
49 of 50 checks passed
@dstaley
dstaley deleted the ds.fix/delete-all-match branch August 11, 2026 16:54
Sign up for freeto 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

@dstaley@wobsoriano
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

fix(e2e): more robust user deletion - #9375

Merged
dstaley merged 8 commits into
mainfrom
ds.fix/delete-all-match
Aug 11, 2026
Merged

fix(e2e): more robust user deletion#9375
dstaley merged 8 commits into
mainfrom
ds.fix/delete-all-match

Conversation

@dstaley

Copy link
Copy Markdown
Member

Description

This PR updates the logic we use to create fake users to embed a run key, which is a hash of the unique data for a single test run. After integration tests finish, we manually clean up users that were created with the run key in their username, email address, or metadata.

This also includes a fix for deleteIfExists that will delete all matching users rather than just the first. This handles the case were we generate the same matching email/phone number across multiple tests. This shouldn't be as much of an issue now that we're storing the run key in the identifier, but it doesn't hurt!

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-botBot commented Aug 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 417bb3b

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

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

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

vercelBot commented Aug 10, 2026

Copy link
Copy Markdown

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

ProjectDeploymentActionsUpdated (UTC)
clerk-js-sandboxReadyReadyPreviewAug 11, 2026 4:47pm
swingsetReadyReadyPreviewAug 11, 2026 4:47pm

Request Review

@pkg-pr-new

pkg-pr-newBot commented Aug 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/electron

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

@clerk/electron-passkeys

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

@clerk/eslint-plugin

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

@clerk/expo

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

@clerk/expo-google-signin

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/hono

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

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

@clerk/upgrade

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

@clerk/vue

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

commit: 417bb3b

@coderabbitai

coderabbitaiBot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro Plus

Run ID: cfafa388-05ce-4b49-8e5b-595bdd7dc0bd

📥 Commits

Reviewing files that changed from the base of the PR and between a326a24 and ad2f98a.

📒 Files selected for processing (1)
  • integration/cleanup/cleanup.setup.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/cli(auto-detected)
  • clerk/clerk-ios(auto-detected)
  • clerk/clerk-android(auto-detected)
🚧 Files skipped from review as they are similar to previous changes (1)
  • integration/cleanup/cleanup.setup.ts

📝 Walkthrough

Walkthrough

Integration tests now receive a unique run key from CI. Generated users include a derived E2E marker in identifiers and private metadata. Cleanup discovers and deletes users for the active run, verifies that no marked users remain, and reports run-scoped failures. Turbo passes the run key through the environment. Two changeset files were added.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • clerk/javascript#9374: Both PRs modify integration/testUtils/usersService.ts to tag generated fake users with run metadata for scoped cleanup.

Suggested reviewers:maxyinger

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Title check✅ PassedThe title accurately describes the improved E2E user deletion logic, which is a primary part of the changeset.
Description check✅ PassedThe description directly explains run-key-based user cleanup and deletion of all matching users.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.

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

@coderabbitaicoderabbitaiBot 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: 2

🤖 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/testUtils/usersService.ts`:
- Around line 205-207: Update the empty-user branch in the user cleanup flow to
replace the interpolated opts.email and opts.phoneNumber values with a generic
cleanup message, ensuring no supplied user identifier is written to logs while
preserving the early return.
In `@turbo.json`:
- Line 37: Update the Turbo integration task configuration containing
INTEGRATION_TEST_RUN_KEY so CI integration tasks do not reuse cached results:
set cache to false for those tasks, or move INTEGRATION_TEST_RUN_KEY into
globalEnv to include it in the cache key.
🪄 Autofix

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: a309c6ba-20fe-4646-87e4-e7652685a849

📥 Commits

Reviewing files that changed from the base of the PR and between 52ec5cd and d76132e.

📒 Files selected for processing (7)
  • .changeset/fair-llamas-shout.md
  • .changeset/silver-lands-cut.md
  • .github/workflows/ci.yml
  • integration/cleanup/cleanup.setup.ts
  • integration/testUtils/e2eRun.ts
  • integration/testUtils/usersService.ts
  • turbo.json
🔗 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/cli(auto-detected)
  • clerk/clerk-ios(auto-detected)
  • clerk/clerk-android(auto-detected)

Comment on lines +205 to 207
if (ids.size === 0) {
console.log(`User "${opts.email || opts.phoneNumber}" does not exist!`);
return;

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.

🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

Do not log the supplied email address or phone number.

Line 206 writes a user identifier to CI logs. Log a generic cleanup message instead.

Proposed fix
- console.log(`User "${opts.email || opts.phoneNumber}" does not exist!`);+ console.log('No user exists for the supplied cleanup criteria.');
📝 Committable suggestion

‼️IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if(ids.size===0){
console.log(`User "${opts.email||opts.phoneNumber}" does not exist!`);
return;
if(ids.size===0){
console.log('No user exists for the supplied cleanup criteria.');
return;
🧰 Tools
🪛 ast-grep (0.45.0)

[warning] 205-205: Avoid logging sensitive data
Context: console.log(User "${opts.email || opts.phoneNumber}" does not exist!)
Note: [CWE-532] Insertion of Sensitive Information into Log File.

(log-sensitive-data-typescript)

🤖 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/testUtils/usersService.ts` around lines 205 - 207, Update the
empty-user branch in the user cleanup flow to replace the interpolated
opts.email and opts.phoneNumber values with a generic cleanup message, ensuring
no supplied user identifier is written to logs while preserving the early
return.

Sources: Coding guidelines, Linters/SAST tools

Comment threadturbo.json
"globalPassThroughEnv": [
"AWS_SECRET_KEY",
"GITHUB_TOKEN",
"INTEGRATION_TEST_RUN_KEY",

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
# Every integration task must report cache=false.
jq -r ' (.tasks // {}) | to_entries[] | select(.key | test("test:integration")) | "\(.key): cache=\(.value.cache // true)"' turbo.json

Repository: clerk/javascript

Length of output: 1212


🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
printf'%s\n''--- turbo.json ---'
cat -n turbo.json | sed -n '1,90p'printf'%s\n''--- Turbo version and integration scripts ---'
rg -n '"turbo"|test:integration|INTEGRATION_TEST_RUN_KEY' package.json pnpm-lock.yaml packages apps examples .github 2>/dev/null | head -240

Repository: clerk/javascript

Length of output: 7965


🌐 Web query:

Turborepo globalPassThroughEnv cache key behavior passThroughEnv cacheable task

💡 Result:

In Turborepo, both globalPassThroughEnv and passThroughEnv serve to expose environment variables to task runtimes without including them in the task's cache key [1][2][3]. Because these variables are intentionally omitted from the hashing process, changes to their values will not trigger a cache miss, even if the change would logically affect the output of the task [1][4]. The fundamental behaviors for these configurations are: 1. Cache Key Exclusion: Variables listed in either globalPassThroughEnv or passThroughEnv do not contribute to the task hash [2][3]. Consequently, Turborepo may serve a cached result even if the underlying environment variable has changed [1][4]. This is why these keys should only be used for variables that do not affect the build output, such as authentication tokens (e.g., SENTRY_AUTH_TOKEN), CI metadata, or credentials consumed at runtime after the build process [2][4]. 2. Runtime Exposure: By including a variable in either key, you satisfy Turborepo's Strict Environment Mode, ensuring the task has access to that variable at runtime [1][5][3]. If a task attempts to access an environment variable that is not accounted for in env, globalEnv, passThroughEnv, or globalPassThroughEnv while in Strict Mode, the task may fail [1][5]. 3. Scope Differences: - globalPassThroughEnv (or global.passThroughEnv when using the global configuration flag) applies the passthrough behavior to all tasks within the repository [2][6]. - passThroughEnv applies only to the specific task where it is configured [3]. If you need a change in an environment variable to invalidate the cache and trigger a rebuild, you must include that variable in env or globalEnv instead of the passthrough keys [1][3].

Citations:


🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
printf'%s\n''--- integration task definitions ---'
rg -n -C 3 '"[`#/`]?test:integration|test:integration' turbo.json
printf'%s\n''--- CI Turbo arguments and integration invocation ---'
sed -n '400,535p' .github/workflows/ci.yml
sed -n '260,300p' .github/workflows/e2e-staging.yml
printf'%s\n''--- exact task keys parsed from turbo.json ---'
jq -r '(.tasks // {}) | to_entries[] | select(.key | contains("test:integration")) | [.key, (.value.cache // true | tostring)] | `@tsv`' turbo.json

Repository: clerk/javascript

Length of output: 16346


🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
python3 - <<'PY'import jsonfrom pathlib import Pathconfig = json.loads(Path("turbo.json").read_text())tasks = config.get("tasks", {})matches = [(name, task.get("cache", True)) for name, task in tasks.items() if "test:integration" in name]print("matching task count:", len(matches))for name, cache in matches: print(f"{name}: cache={cache}")PY

Repository: clerk/javascript

Length of output: 1236


🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
printf'%s\n''--- all Turbo force/argument settings ---'
rg -n -C 4 'TURBO_(ARGS|FORCE)|pnpm turbo test:integration|pnpm turbo run test:integration' .github/workflows package.json
printf'%s\n''--- CI workflow environment and matrix context ---'
sed -n '1,120p' .github/workflows/ci.yml
sed -n '380,445p' .github/workflows/ci.yml
sed -n '495,535p' .github/workflows/ci.yml
printf'%s\n''--- staging workflow context ---'
sed -n '1,110p' .github/workflows/e2e-staging.yml
sed -n '270,320p' .github/workflows/e2e-staging.yml

Repository: clerk/javascript

Length of output: 30087


Disable caching for CI integration tasks.

The CI integration job does not set TURBO_FORCE, and all 25 integration tasks inherit cache: true. globalPassThroughEnv does not affect the cache key. Set cache: false for these tasks, or move INTEGRATION_TEST_RUN_KEY to globalEnv.

🤖 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 `@turbo.json` at line 37, Update the Turbo integration task configuration
containing INTEGRATION_TEST_RUN_KEY so CI integration tasks do not reuse cached
results: set cache to false for those tasks, or move INTEGRATION_TEST_RUN_KEY
into globalEnv to include it in the cache key.

@wobsorianowobsoriano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Extra changesets but everything looks good!

@dstaley
dstaley merged commit 07344ca into mainAug 11, 2026
49 of 50 checks passed
@dstaley
dstaley deleted the ds.fix/delete-all-match branch August 11, 2026 16:54
Sign up for freeto 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

@dstaley@wobsoriano
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

fix(e2e): more robust user deletion - #9375

Merged
dstaley merged 8 commits into
mainfrom
ds.fix/delete-all-match
Aug 11, 2026
Merged

fix(e2e): more robust user deletion#9375
dstaley merged 8 commits into
mainfrom
ds.fix/delete-all-match

Conversation

@dstaley

Copy link
Copy Markdown
Member

Description

This PR updates the logic we use to create fake users to embed a run key, which is a hash of the unique data for a single test run. After integration tests finish, we manually clean up users that were created with the run key in their username, email address, or metadata.

This also includes a fix for deleteIfExists that will delete all matching users rather than just the first. This handles the case were we generate the same matching email/phone number across multiple tests. This shouldn't be as much of an issue now that we're storing the run key in the identifier, but it doesn't hurt!

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-botBot commented Aug 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 417bb3b

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

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

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

vercelBot commented Aug 10, 2026

Copy link
Copy Markdown

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

ProjectDeploymentActionsUpdated (UTC)
clerk-js-sandboxReadyReadyPreviewAug 11, 2026 4:47pm
swingsetReadyReadyPreviewAug 11, 2026 4:47pm

Request Review

@pkg-pr-new

pkg-pr-newBot commented Aug 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/electron

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

@clerk/electron-passkeys

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

@clerk/eslint-plugin

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

@clerk/expo

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

@clerk/expo-google-signin

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/hono

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

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

@clerk/upgrade

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

@clerk/vue

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

commit: 417bb3b

@coderabbitai

coderabbitaiBot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro Plus

Run ID: cfafa388-05ce-4b49-8e5b-595bdd7dc0bd

📥 Commits

Reviewing files that changed from the base of the PR and between a326a24 and ad2f98a.

📒 Files selected for processing (1)
  • integration/cleanup/cleanup.setup.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/cli(auto-detected)
  • clerk/clerk-ios(auto-detected)
  • clerk/clerk-android(auto-detected)
🚧 Files skipped from review as they are similar to previous changes (1)
  • integration/cleanup/cleanup.setup.ts

📝 Walkthrough

Walkthrough

Integration tests now receive a unique run key from CI. Generated users include a derived E2E marker in identifiers and private metadata. Cleanup discovers and deletes users for the active run, verifies that no marked users remain, and reports run-scoped failures. Turbo passes the run key through the environment. Two changeset files were added.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • clerk/javascript#9374: Both PRs modify integration/testUtils/usersService.ts to tag generated fake users with run metadata for scoped cleanup.

Suggested reviewers:maxyinger

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Title check✅ PassedThe title accurately describes the improved E2E user deletion logic, which is a primary part of the changeset.
Description check✅ PassedThe description directly explains run-key-based user cleanup and deletion of all matching users.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.

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

@coderabbitaicoderabbitaiBot 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: 2

🤖 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/testUtils/usersService.ts`:
- Around line 205-207: Update the empty-user branch in the user cleanup flow to
replace the interpolated opts.email and opts.phoneNumber values with a generic
cleanup message, ensuring no supplied user identifier is written to logs while
preserving the early return.
In `@turbo.json`:
- Line 37: Update the Turbo integration task configuration containing
INTEGRATION_TEST_RUN_KEY so CI integration tasks do not reuse cached results:
set cache to false for those tasks, or move INTEGRATION_TEST_RUN_KEY into
globalEnv to include it in the cache key.
🪄 Autofix

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: a309c6ba-20fe-4646-87e4-e7652685a849

📥 Commits

Reviewing files that changed from the base of the PR and between 52ec5cd and d76132e.

📒 Files selected for processing (7)
  • .changeset/fair-llamas-shout.md
  • .changeset/silver-lands-cut.md
  • .github/workflows/ci.yml
  • integration/cleanup/cleanup.setup.ts
  • integration/testUtils/e2eRun.ts
  • integration/testUtils/usersService.ts
  • turbo.json
🔗 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/cli(auto-detected)
  • clerk/clerk-ios(auto-detected)
  • clerk/clerk-android(auto-detected)

Comment on lines +205 to 207
if (ids.size === 0) {
console.log(`User "${opts.email || opts.phoneNumber}" does not exist!`);
return;

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.

🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

Do not log the supplied email address or phone number.

Line 206 writes a user identifier to CI logs. Log a generic cleanup message instead.

Proposed fix
- console.log(`User "${opts.email || opts.phoneNumber}" does not exist!`);+ console.log('No user exists for the supplied cleanup criteria.');
📝 Committable suggestion

‼️IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if(ids.size===0){
console.log(`User "${opts.email||opts.phoneNumber}" does not exist!`);
return;
if(ids.size===0){
console.log('No user exists for the supplied cleanup criteria.');
return;
🧰 Tools
🪛 ast-grep (0.45.0)

[warning] 205-205: Avoid logging sensitive data
Context: console.log(User "${opts.email || opts.phoneNumber}" does not exist!)
Note: [CWE-532] Insertion of Sensitive Information into Log File.

(log-sensitive-data-typescript)

🤖 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/testUtils/usersService.ts` around lines 205 - 207, Update the
empty-user branch in the user cleanup flow to replace the interpolated
opts.email and opts.phoneNumber values with a generic cleanup message, ensuring
no supplied user identifier is written to logs while preserving the early
return.

Sources: Coding guidelines, Linters/SAST tools

Comment threadturbo.json
"globalPassThroughEnv": [
"AWS_SECRET_KEY",
"GITHUB_TOKEN",
"INTEGRATION_TEST_RUN_KEY",

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
# Every integration task must report cache=false.
jq -r ' (.tasks // {}) | to_entries[] | select(.key | test("test:integration")) | "\(.key): cache=\(.value.cache // true)"' turbo.json

Repository: clerk/javascript

Length of output: 1212


🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
printf'%s\n''--- turbo.json ---'
cat -n turbo.json | sed -n '1,90p'printf'%s\n''--- Turbo version and integration scripts ---'
rg -n '"turbo"|test:integration|INTEGRATION_TEST_RUN_KEY' package.json pnpm-lock.yaml packages apps examples .github 2>/dev/null | head -240

Repository: clerk/javascript

Length of output: 7965


🌐 Web query:

Turborepo globalPassThroughEnv cache key behavior passThroughEnv cacheable task

💡 Result:

In Turborepo, both globalPassThroughEnv and passThroughEnv serve to expose environment variables to task runtimes without including them in the task's cache key [1][2][3]. Because these variables are intentionally omitted from the hashing process, changes to their values will not trigger a cache miss, even if the change would logically affect the output of the task [1][4]. The fundamental behaviors for these configurations are: 1. Cache Key Exclusion: Variables listed in either globalPassThroughEnv or passThroughEnv do not contribute to the task hash [2][3]. Consequently, Turborepo may serve a cached result even if the underlying environment variable has changed [1][4]. This is why these keys should only be used for variables that do not affect the build output, such as authentication tokens (e.g., SENTRY_AUTH_TOKEN), CI metadata, or credentials consumed at runtime after the build process [2][4]. 2. Runtime Exposure: By including a variable in either key, you satisfy Turborepo's Strict Environment Mode, ensuring the task has access to that variable at runtime [1][5][3]. If a task attempts to access an environment variable that is not accounted for in env, globalEnv, passThroughEnv, or globalPassThroughEnv while in Strict Mode, the task may fail [1][5]. 3. Scope Differences: - globalPassThroughEnv (or global.passThroughEnv when using the global configuration flag) applies the passthrough behavior to all tasks within the repository [2][6]. - passThroughEnv applies only to the specific task where it is configured [3]. If you need a change in an environment variable to invalidate the cache and trigger a rebuild, you must include that variable in env or globalEnv instead of the passthrough keys [1][3].

Citations:


🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
printf'%s\n''--- integration task definitions ---'
rg -n -C 3 '"[`#/`]?test:integration|test:integration' turbo.json
printf'%s\n''--- CI Turbo arguments and integration invocation ---'
sed -n '400,535p' .github/workflows/ci.yml
sed -n '260,300p' .github/workflows/e2e-staging.yml
printf'%s\n''--- exact task keys parsed from turbo.json ---'
jq -r '(.tasks // {}) | to_entries[] | select(.key | contains("test:integration")) | [.key, (.value.cache // true | tostring)] | `@tsv`' turbo.json

Repository: clerk/javascript

Length of output: 16346


🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
python3 - <<'PY'import jsonfrom pathlib import Pathconfig = json.loads(Path("turbo.json").read_text())tasks = config.get("tasks", {})matches = [(name, task.get("cache", True)) for name, task in tasks.items() if "test:integration" in name]print("matching task count:", len(matches))for name, cache in matches: print(f"{name}: cache={cache}")PY

Repository: clerk/javascript

Length of output: 1236


🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
printf'%s\n''--- all Turbo force/argument settings ---'
rg -n -C 4 'TURBO_(ARGS|FORCE)|pnpm turbo test:integration|pnpm turbo run test:integration' .github/workflows package.json
printf'%s\n''--- CI workflow environment and matrix context ---'
sed -n '1,120p' .github/workflows/ci.yml
sed -n '380,445p' .github/workflows/ci.yml
sed -n '495,535p' .github/workflows/ci.yml
printf'%s\n''--- staging workflow context ---'
sed -n '1,110p' .github/workflows/e2e-staging.yml
sed -n '270,320p' .github/workflows/e2e-staging.yml

Repository: clerk/javascript

Length of output: 30087


Disable caching for CI integration tasks.

The CI integration job does not set TURBO_FORCE, and all 25 integration tasks inherit cache: true. globalPassThroughEnv does not affect the cache key. Set cache: false for these tasks, or move INTEGRATION_TEST_RUN_KEY to globalEnv.

🤖 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 `@turbo.json` at line 37, Update the Turbo integration task configuration
containing INTEGRATION_TEST_RUN_KEY so CI integration tasks do not reuse cached
results: set cache to false for those tasks, or move INTEGRATION_TEST_RUN_KEY
into globalEnv to include it in the cache key.

@wobsorianowobsoriano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Extra changesets but everything looks good!

@dstaley
dstaley merged commit 07344ca into mainAug 11, 2026
49 of 50 checks passed
@dstaley
dstaley deleted the ds.fix/delete-all-match branch August 11, 2026 16:54
Sign up for freeto 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

@dstaley@wobsoriano
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

fix(e2e): more robust user deletion - #9375

Merged
dstaley merged 8 commits into
mainfrom
ds.fix/delete-all-match
Aug 11, 2026
Merged

fix(e2e): more robust user deletion#9375
dstaley merged 8 commits into
mainfrom
ds.fix/delete-all-match

Conversation

@dstaley

Copy link
Copy Markdown
Member

Description

This PR updates the logic we use to create fake users to embed a run key, which is a hash of the unique data for a single test run. After integration tests finish, we manually clean up users that were created with the run key in their username, email address, or metadata.

This also includes a fix for deleteIfExists that will delete all matching users rather than just the first. This handles the case were we generate the same matching email/phone number across multiple tests. This shouldn't be as much of an issue now that we're storing the run key in the identifier, but it doesn't hurt!

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-botBot commented Aug 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 417bb3b

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

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

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

vercelBot commented Aug 10, 2026

Copy link
Copy Markdown

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

ProjectDeploymentActionsUpdated (UTC)
clerk-js-sandboxReadyReadyPreviewAug 11, 2026 4:47pm
swingsetReadyReadyPreviewAug 11, 2026 4:47pm

Request Review

@pkg-pr-new

pkg-pr-newBot commented Aug 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/electron

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

@clerk/electron-passkeys

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

@clerk/eslint-plugin

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

@clerk/expo

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

@clerk/expo-google-signin

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/hono

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

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

@clerk/upgrade

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

@clerk/vue

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

commit: 417bb3b

@coderabbitai

coderabbitaiBot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro Plus

Run ID: cfafa388-05ce-4b49-8e5b-595bdd7dc0bd

📥 Commits

Reviewing files that changed from the base of the PR and between a326a24 and ad2f98a.

📒 Files selected for processing (1)
  • integration/cleanup/cleanup.setup.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/cli(auto-detected)
  • clerk/clerk-ios(auto-detected)
  • clerk/clerk-android(auto-detected)
🚧 Files skipped from review as they are similar to previous changes (1)
  • integration/cleanup/cleanup.setup.ts

📝 Walkthrough

Walkthrough

Integration tests now receive a unique run key from CI. Generated users include a derived E2E marker in identifiers and private metadata. Cleanup discovers and deletes users for the active run, verifies that no marked users remain, and reports run-scoped failures. Turbo passes the run key through the environment. Two changeset files were added.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • clerk/javascript#9374: Both PRs modify integration/testUtils/usersService.ts to tag generated fake users with run metadata for scoped cleanup.

Suggested reviewers:maxyinger

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Title check✅ PassedThe title accurately describes the improved E2E user deletion logic, which is a primary part of the changeset.
Description check✅ PassedThe description directly explains run-key-based user cleanup and deletion of all matching users.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.

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

@coderabbitaicoderabbitaiBot 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: 2

🤖 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/testUtils/usersService.ts`:
- Around line 205-207: Update the empty-user branch in the user cleanup flow to
replace the interpolated opts.email and opts.phoneNumber values with a generic
cleanup message, ensuring no supplied user identifier is written to logs while
preserving the early return.
In `@turbo.json`:
- Line 37: Update the Turbo integration task configuration containing
INTEGRATION_TEST_RUN_KEY so CI integration tasks do not reuse cached results:
set cache to false for those tasks, or move INTEGRATION_TEST_RUN_KEY into
globalEnv to include it in the cache key.
🪄 Autofix

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: a309c6ba-20fe-4646-87e4-e7652685a849

📥 Commits

Reviewing files that changed from the base of the PR and between 52ec5cd and d76132e.

📒 Files selected for processing (7)
  • .changeset/fair-llamas-shout.md
  • .changeset/silver-lands-cut.md
  • .github/workflows/ci.yml
  • integration/cleanup/cleanup.setup.ts
  • integration/testUtils/e2eRun.ts
  • integration/testUtils/usersService.ts
  • turbo.json
🔗 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/cli(auto-detected)
  • clerk/clerk-ios(auto-detected)
  • clerk/clerk-android(auto-detected)

Comment on lines +205 to 207
if (ids.size === 0) {
console.log(`User "${opts.email || opts.phoneNumber}" does not exist!`);
return;

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.

🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

Do not log the supplied email address or phone number.

Line 206 writes a user identifier to CI logs. Log a generic cleanup message instead.

Proposed fix
- console.log(`User "${opts.email || opts.phoneNumber}" does not exist!`);+ console.log('No user exists for the supplied cleanup criteria.');
📝 Committable suggestion

‼️IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if(ids.size===0){
console.log(`User "${opts.email||opts.phoneNumber}" does not exist!`);
return;
if(ids.size===0){
console.log('No user exists for the supplied cleanup criteria.');
return;
🧰 Tools
🪛 ast-grep (0.45.0)

[warning] 205-205: Avoid logging sensitive data
Context: console.log(User "${opts.email || opts.phoneNumber}" does not exist!)
Note: [CWE-532] Insertion of Sensitive Information into Log File.

(log-sensitive-data-typescript)

🤖 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/testUtils/usersService.ts` around lines 205 - 207, Update the
empty-user branch in the user cleanup flow to replace the interpolated
opts.email and opts.phoneNumber values with a generic cleanup message, ensuring
no supplied user identifier is written to logs while preserving the early
return.

Sources: Coding guidelines, Linters/SAST tools

Comment threadturbo.json
"globalPassThroughEnv": [
"AWS_SECRET_KEY",
"GITHUB_TOKEN",
"INTEGRATION_TEST_RUN_KEY",

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
# Every integration task must report cache=false.
jq -r ' (.tasks // {}) | to_entries[] | select(.key | test("test:integration")) | "\(.key): cache=\(.value.cache // true)"' turbo.json

Repository: clerk/javascript

Length of output: 1212


🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
printf'%s\n''--- turbo.json ---'
cat -n turbo.json | sed -n '1,90p'printf'%s\n''--- Turbo version and integration scripts ---'
rg -n '"turbo"|test:integration|INTEGRATION_TEST_RUN_KEY' package.json pnpm-lock.yaml packages apps examples .github 2>/dev/null | head -240

Repository: clerk/javascript

Length of output: 7965


🌐 Web query:

Turborepo globalPassThroughEnv cache key behavior passThroughEnv cacheable task

💡 Result:

In Turborepo, both globalPassThroughEnv and passThroughEnv serve to expose environment variables to task runtimes without including them in the task's cache key [1][2][3]. Because these variables are intentionally omitted from the hashing process, changes to their values will not trigger a cache miss, even if the change would logically affect the output of the task [1][4]. The fundamental behaviors for these configurations are: 1. Cache Key Exclusion: Variables listed in either globalPassThroughEnv or passThroughEnv do not contribute to the task hash [2][3]. Consequently, Turborepo may serve a cached result even if the underlying environment variable has changed [1][4]. This is why these keys should only be used for variables that do not affect the build output, such as authentication tokens (e.g., SENTRY_AUTH_TOKEN), CI metadata, or credentials consumed at runtime after the build process [2][4]. 2. Runtime Exposure: By including a variable in either key, you satisfy Turborepo's Strict Environment Mode, ensuring the task has access to that variable at runtime [1][5][3]. If a task attempts to access an environment variable that is not accounted for in env, globalEnv, passThroughEnv, or globalPassThroughEnv while in Strict Mode, the task may fail [1][5]. 3. Scope Differences: - globalPassThroughEnv (or global.passThroughEnv when using the global configuration flag) applies the passthrough behavior to all tasks within the repository [2][6]. - passThroughEnv applies only to the specific task where it is configured [3]. If you need a change in an environment variable to invalidate the cache and trigger a rebuild, you must include that variable in env or globalEnv instead of the passthrough keys [1][3].

Citations:


🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
printf'%s\n''--- integration task definitions ---'
rg -n -C 3 '"[`#/`]?test:integration|test:integration' turbo.json
printf'%s\n''--- CI Turbo arguments and integration invocation ---'
sed -n '400,535p' .github/workflows/ci.yml
sed -n '260,300p' .github/workflows/e2e-staging.yml
printf'%s\n''--- exact task keys parsed from turbo.json ---'
jq -r '(.tasks // {}) | to_entries[] | select(.key | contains("test:integration")) | [.key, (.value.cache // true | tostring)] | `@tsv`' turbo.json

Repository: clerk/javascript

Length of output: 16346


🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
python3 - <<'PY'import jsonfrom pathlib import Pathconfig = json.loads(Path("turbo.json").read_text())tasks = config.get("tasks", {})matches = [(name, task.get("cache", True)) for name, task in tasks.items() if "test:integration" in name]print("matching task count:", len(matches))for name, cache in matches: print(f"{name}: cache={cache}")PY

Repository: clerk/javascript

Length of output: 1236


🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
printf'%s\n''--- all Turbo force/argument settings ---'
rg -n -C 4 'TURBO_(ARGS|FORCE)|pnpm turbo test:integration|pnpm turbo run test:integration' .github/workflows package.json
printf'%s\n''--- CI workflow environment and matrix context ---'
sed -n '1,120p' .github/workflows/ci.yml
sed -n '380,445p' .github/workflows/ci.yml
sed -n '495,535p' .github/workflows/ci.yml
printf'%s\n''--- staging workflow context ---'
sed -n '1,110p' .github/workflows/e2e-staging.yml
sed -n '270,320p' .github/workflows/e2e-staging.yml

Repository: clerk/javascript

Length of output: 30087


Disable caching for CI integration tasks.

The CI integration job does not set TURBO_FORCE, and all 25 integration tasks inherit cache: true. globalPassThroughEnv does not affect the cache key. Set cache: false for these tasks, or move INTEGRATION_TEST_RUN_KEY to globalEnv.

🤖 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 `@turbo.json` at line 37, Update the Turbo integration task configuration
containing INTEGRATION_TEST_RUN_KEY so CI integration tasks do not reuse cached
results: set cache to false for those tasks, or move INTEGRATION_TEST_RUN_KEY
into globalEnv to include it in the cache key.

@wobsorianowobsoriano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Extra changesets but everything looks good!

@dstaley
dstaley merged commit 07344ca into mainAug 11, 2026
49 of 50 checks passed
@dstaley
dstaley deleted the ds.fix/delete-all-match branch August 11, 2026 16:54
Sign up for freeto 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

@dstaley@wobsoriano
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

fix(e2e): more robust user deletion - #9375

Merged
dstaley merged 8 commits into
mainfrom
ds.fix/delete-all-match
Aug 11, 2026
Merged

fix(e2e): more robust user deletion#9375
dstaley merged 8 commits into
mainfrom
ds.fix/delete-all-match

Conversation

@dstaley

Copy link
Copy Markdown
Member

Description

This PR updates the logic we use to create fake users to embed a run key, which is a hash of the unique data for a single test run. After integration tests finish, we manually clean up users that were created with the run key in their username, email address, or metadata.

This also includes a fix for deleteIfExists that will delete all matching users rather than just the first. This handles the case were we generate the same matching email/phone number across multiple tests. This shouldn't be as much of an issue now that we're storing the run key in the identifier, but it doesn't hurt!

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-botBot commented Aug 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 417bb3b

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

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

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

vercelBot commented Aug 10, 2026

Copy link
Copy Markdown

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

ProjectDeploymentActionsUpdated (UTC)
clerk-js-sandboxReadyReadyPreviewAug 11, 2026 4:47pm
swingsetReadyReadyPreviewAug 11, 2026 4:47pm

Request Review

@pkg-pr-new

pkg-pr-newBot commented Aug 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/electron

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

@clerk/electron-passkeys

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

@clerk/eslint-plugin

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

@clerk/expo

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

@clerk/expo-google-signin

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/hono

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

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

@clerk/upgrade

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

@clerk/vue

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

commit: 417bb3b

@coderabbitai

coderabbitaiBot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro Plus

Run ID: cfafa388-05ce-4b49-8e5b-595bdd7dc0bd

📥 Commits

Reviewing files that changed from the base of the PR and between a326a24 and ad2f98a.

📒 Files selected for processing (1)
  • integration/cleanup/cleanup.setup.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/cli(auto-detected)
  • clerk/clerk-ios(auto-detected)
  • clerk/clerk-android(auto-detected)
🚧 Files skipped from review as they are similar to previous changes (1)
  • integration/cleanup/cleanup.setup.ts

📝 Walkthrough

Walkthrough

Integration tests now receive a unique run key from CI. Generated users include a derived E2E marker in identifiers and private metadata. Cleanup discovers and deletes users for the active run, verifies that no marked users remain, and reports run-scoped failures. Turbo passes the run key through the environment. Two changeset files were added.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • clerk/javascript#9374: Both PRs modify integration/testUtils/usersService.ts to tag generated fake users with run metadata for scoped cleanup.

Suggested reviewers:maxyinger

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Title check✅ PassedThe title accurately describes the improved E2E user deletion logic, which is a primary part of the changeset.
Description check✅ PassedThe description directly explains run-key-based user cleanup and deletion of all matching users.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.

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

@coderabbitaicoderabbitaiBot 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: 2

🤖 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/testUtils/usersService.ts`:
- Around line 205-207: Update the empty-user branch in the user cleanup flow to
replace the interpolated opts.email and opts.phoneNumber values with a generic
cleanup message, ensuring no supplied user identifier is written to logs while
preserving the early return.
In `@turbo.json`:
- Line 37: Update the Turbo integration task configuration containing
INTEGRATION_TEST_RUN_KEY so CI integration tasks do not reuse cached results:
set cache to false for those tasks, or move INTEGRATION_TEST_RUN_KEY into
globalEnv to include it in the cache key.
🪄 Autofix

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: a309c6ba-20fe-4646-87e4-e7652685a849

📥 Commits

Reviewing files that changed from the base of the PR and between 52ec5cd and d76132e.

📒 Files selected for processing (7)
  • .changeset/fair-llamas-shout.md
  • .changeset/silver-lands-cut.md
  • .github/workflows/ci.yml
  • integration/cleanup/cleanup.setup.ts
  • integration/testUtils/e2eRun.ts
  • integration/testUtils/usersService.ts
  • turbo.json
🔗 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/cli(auto-detected)
  • clerk/clerk-ios(auto-detected)
  • clerk/clerk-android(auto-detected)

Comment on lines +205 to 207
if (ids.size === 0) {
console.log(`User "${opts.email || opts.phoneNumber}" does not exist!`);
return;

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.

🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

Do not log the supplied email address or phone number.

Line 206 writes a user identifier to CI logs. Log a generic cleanup message instead.

Proposed fix
- console.log(`User "${opts.email || opts.phoneNumber}" does not exist!`);+ console.log('No user exists for the supplied cleanup criteria.');
📝 Committable suggestion

‼️IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if(ids.size===0){
console.log(`User "${opts.email||opts.phoneNumber}" does not exist!`);
return;
if(ids.size===0){
console.log('No user exists for the supplied cleanup criteria.');
return;
🧰 Tools
🪛 ast-grep (0.45.0)

[warning] 205-205: Avoid logging sensitive data
Context: console.log(User "${opts.email || opts.phoneNumber}" does not exist!)
Note: [CWE-532] Insertion of Sensitive Information into Log File.

(log-sensitive-data-typescript)

🤖 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/testUtils/usersService.ts` around lines 205 - 207, Update the
empty-user branch in the user cleanup flow to replace the interpolated
opts.email and opts.phoneNumber values with a generic cleanup message, ensuring
no supplied user identifier is written to logs while preserving the early
return.

Sources: Coding guidelines, Linters/SAST tools

Comment threadturbo.json
"globalPassThroughEnv": [
"AWS_SECRET_KEY",
"GITHUB_TOKEN",
"INTEGRATION_TEST_RUN_KEY",

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
# Every integration task must report cache=false.
jq -r ' (.tasks // {}) | to_entries[] | select(.key | test("test:integration")) | "\(.key): cache=\(.value.cache // true)"' turbo.json

Repository: clerk/javascript

Length of output: 1212


🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
printf'%s\n''--- turbo.json ---'
cat -n turbo.json | sed -n '1,90p'printf'%s\n''--- Turbo version and integration scripts ---'
rg -n '"turbo"|test:integration|INTEGRATION_TEST_RUN_KEY' package.json pnpm-lock.yaml packages apps examples .github 2>/dev/null | head -240

Repository: clerk/javascript

Length of output: 7965


🌐 Web query:

Turborepo globalPassThroughEnv cache key behavior passThroughEnv cacheable task

💡 Result:

In Turborepo, both globalPassThroughEnv and passThroughEnv serve to expose environment variables to task runtimes without including them in the task's cache key [1][2][3]. Because these variables are intentionally omitted from the hashing process, changes to their values will not trigger a cache miss, even if the change would logically affect the output of the task [1][4]. The fundamental behaviors for these configurations are: 1. Cache Key Exclusion: Variables listed in either globalPassThroughEnv or passThroughEnv do not contribute to the task hash [2][3]. Consequently, Turborepo may serve a cached result even if the underlying environment variable has changed [1][4]. This is why these keys should only be used for variables that do not affect the build output, such as authentication tokens (e.g., SENTRY_AUTH_TOKEN), CI metadata, or credentials consumed at runtime after the build process [2][4]. 2. Runtime Exposure: By including a variable in either key, you satisfy Turborepo's Strict Environment Mode, ensuring the task has access to that variable at runtime [1][5][3]. If a task attempts to access an environment variable that is not accounted for in env, globalEnv, passThroughEnv, or globalPassThroughEnv while in Strict Mode, the task may fail [1][5]. 3. Scope Differences: - globalPassThroughEnv (or global.passThroughEnv when using the global configuration flag) applies the passthrough behavior to all tasks within the repository [2][6]. - passThroughEnv applies only to the specific task where it is configured [3]. If you need a change in an environment variable to invalidate the cache and trigger a rebuild, you must include that variable in env or globalEnv instead of the passthrough keys [1][3].

Citations:


🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
printf'%s\n''--- integration task definitions ---'
rg -n -C 3 '"[`#/`]?test:integration|test:integration' turbo.json
printf'%s\n''--- CI Turbo arguments and integration invocation ---'
sed -n '400,535p' .github/workflows/ci.yml
sed -n '260,300p' .github/workflows/e2e-staging.yml
printf'%s\n''--- exact task keys parsed from turbo.json ---'
jq -r '(.tasks // {}) | to_entries[] | select(.key | contains("test:integration")) | [.key, (.value.cache // true | tostring)] | `@tsv`' turbo.json

Repository: clerk/javascript

Length of output: 16346


🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
python3 - <<'PY'import jsonfrom pathlib import Pathconfig = json.loads(Path("turbo.json").read_text())tasks = config.get("tasks", {})matches = [(name, task.get("cache", True)) for name, task in tasks.items() if "test:integration" in name]print("matching task count:", len(matches))for name, cache in matches: print(f"{name}: cache={cache}")PY

Repository: clerk/javascript

Length of output: 1236


🏁 Script executed:

#!/usr/bin/env bashset -euo pipefail
printf'%s\n''--- all Turbo force/argument settings ---'
rg -n -C 4 'TURBO_(ARGS|FORCE)|pnpm turbo test:integration|pnpm turbo run test:integration' .github/workflows package.json
printf'%s\n''--- CI workflow environment and matrix context ---'
sed -n '1,120p' .github/workflows/ci.yml
sed -n '380,445p' .github/workflows/ci.yml
sed -n '495,535p' .github/workflows/ci.yml
printf'%s\n''--- staging workflow context ---'
sed -n '1,110p' .github/workflows/e2e-staging.yml
sed -n '270,320p' .github/workflows/e2e-staging.yml

Repository: clerk/javascript

Length of output: 30087


Disable caching for CI integration tasks.

The CI integration job does not set TURBO_FORCE, and all 25 integration tasks inherit cache: true. globalPassThroughEnv does not affect the cache key. Set cache: false for these tasks, or move INTEGRATION_TEST_RUN_KEY to globalEnv.

🤖 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 `@turbo.json` at line 37, Update the Turbo integration task configuration
containing INTEGRATION_TEST_RUN_KEY so CI integration tasks do not reuse cached
results: set cache to false for those tasks, or move INTEGRATION_TEST_RUN_KEY
into globalEnv to include it in the cache key.

@wobsorianowobsoriano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Extra changesets but everything looks good!

@dstaley
dstaley merged commit 07344ca into mainAug 11, 2026
49 of 50 checks passed
@dstaley
dstaley deleted the ds.fix/delete-all-match branch August 11, 2026 16:54
Sign up for freeto 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

@dstaley@wobsoriano