Skip to content

fix(tests): stop the Slack install test overwriting the auth secret - #338

Merged
imshashank merged 1 commit into
mainfrom
fix/web-test-auth-secret-leak
Aug 19, 2026
Merged

imshashank merged 1 commit into
mainfrom
fix/web-test-auth-secret-leak

Conversation

@imshashank

@imshashank imshashank commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

What broke

main has been red since aa3e922. One test fails in the Unit and integration tests job:

(fail) MCP authorize PKCE boundary > binds authorization and refresh tokens to the consented workspace grant
DomainError: That access token is not valid.
  at verifyMcpAccessToken (packages/core/src/auth/mcp-token.ts:76:21)

It passes in isolation and fails only in a full-suite run, which is why it survived review on #323.

Why

apps/web/tests/features/settings/integrations-connect-slack.test.ts, added in #323, sets the auth secret at module scope:

process.env['BETTER_AUTH_SECRET'] = 'slack-install-test-secret-123';

Module scope means the whole test process, not that file. Bun loads test files into one process, so from the moment this file is loaded every other test sees the new secret. MCP access tokens are signed with BETTER_AUTH_SECRET, so a token issued under the real secret no longer verifies once the file has been loaded, and verifyMcpAccessToken correctly rejects it.

The assignment was never needed. BETTER_AUTH_SECRET already comes from the repository .env locally and from the workflow environment in CI.

How I confirmed it

Full apps/web suite, same lane and same database, only this line varying:

tree result
a447d5a5, before the three merges 16 fail, PKCE passes
aa3e922d, current main 17 fail, PKCE fails
aa3e922d with integrations-connect-slack.test.ts removed 16 fail, PKCE passes
aa3e922d with only this one line removed 16 fail, PKCE passes

I also ruled out two other candidates on the way: removing the registry.test.ts file added by #334 changes nothing, and rewriting describe.serial to describe changes nothing.

The remaining 16 are the pre-existing full-suite failures that are also present on a447d5a5 and pass in isolation. They are a separate problem and not touched here.

Verification

  • apps/web/tests/features/settings/integrations-connect-slack.test.ts on its own: 4 pass, 0 fail
  • apps/web/tests/app/api/auth on its own: 15 pass, 0 fail
  • Full apps/web suite: 2240 pass, 16 fail, matching a447d5a5
  • bun run lint and bun run check-comments clean

Worth a follow up separately: a test that mutates process.env at module scope can break any other test in the process, and nothing catches it. The 16 remaining full-suite failures are probably worth their own issue too, since they mean a local bun run verify cannot be green today.

Greptile Summary

Removes an unnecessary module-scope BETTER_AUTH_SECRET override from the Slack installation test.

  • Prevents the test file from mutating process-wide authentication state.
  • Preserves the Slack installation test behavior because its exercised code path does not consume this secret.

Confidence Score: 5/5

The PR appears safe to merge, with no actionable defects identified in the changed test.

The removed environment assignment is unused by the Slack installation path, while its removal prevents unrelated tests from observing an overwritten authentication secret.

Important Files Changed

Filename Overview
apps/web/tests/features/settings/integrations-connect-slack.test.ts Safely removes a process-wide environment mutation that caused order-dependent authentication failures elsewhere in the shared test process.

Reviews (1): Last reviewed commit: "fix(tests): stop the Slack install test ..." | Re-trigger Greptile

The Slack install test set BETTER_AUTH_SECRET at module scope, which
changes it for the whole test process rather than for that file. MCP
access tokens are signed with that secret, so a token issued before the
file loaded no longer verified afterwards and the MCP authorize PKCE
boundary test failed with an invalid access token.

The secret already comes from the repository .env in local runs and from
the workflow environment in CI, so the assignment was never needed.
@imshashank
imshashank requested a review from pulkitxm as a code owner August 19, 2026 06:42
@vercel

vercel Bot commented Aug 19, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
orbit Error Error Aug 19, 2026 6:42am

Request Review

@imshashank imshashank added bug Something is broken tests Test coverage and test infrastructure area: web The Next.js app and its UI ci Workflows, tooling and repo automation labels Aug 19, 2026
@github-actions github-actions Bot removed bug Something is broken ci Workflows, tooling and repo automation labels Aug 19, 2026
@coderabbitai

coderabbitai Bot commented Aug 19, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: afd13be2-a30c-4c7e-ae2a-54d4eae05346

📥 Commits

Reviewing files that changed from the base of the PR and between aa3e922 and 423682c.

📒 Files selected for processing (1)
  • apps/web/tests/features/settings/integrations-connect-slack.test.ts
💤 Files with no reviewable changes (1)
  • apps/web/tests/features/settings/integrations-connect-slack.test.ts

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The Slack integration test setup no longer assigns BETTER_AUTH_SECRET to a Slack-specific value. Test cases and helper logic remain unchanged.

Changes

Cohort / File(s) Summary
Slack test cleanup
apps/web/tests/features/settings/integrations-connect-slack.test.ts
Removed the Slack-specific BETTER_AUTH_SECRET assignment from test setup.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Merge Risk: ⚪ Minimal · up to 42368

This change stops the Slack install test from overwriting the shared authentication secret, preventing unrelated tests from rejecting valid tokens; no actionable merge-blocking risk remains after normal checks.

Suggested reviewers: pulkitxm

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the main change: removing the Slack install test's auth-secret override.
Description check ✅ Passed The description explains the secret mutation, the resulting MCP test failure, the fix, and verification results.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/web-test-auth-secret-leak

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@imshashank
imshashank merged commit a966363 into main Aug 19, 2026
14 of 15 checks passed
@imshashank
imshashank deleted the fix/web-test-auth-secret-leak branch August 19, 2026 06:53

This branch had an error being deployed

1 failed deployment
Preview — 423682ce Deployed Aug 19, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: web The Next.js app and its UI tests Test coverage and test infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant