Skip to content

fix(nextjs): remove stray double space in clerkMiddleware detection error - #9408

Open
manovotny wants to merge 2 commits into
mainfrom
manovotny/recursing-golick-9ac1a8
Open

fix(nextjs): remove stray double space in clerkMiddleware detection error#9408
manovotny wants to merge 2 commits into
mainfrom
manovotny/recursing-golick-9ac1a8

Conversation

@manovotny

@manovotny manovotny commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Description

The getAuth() "Clerk can't detect usage of clerkMiddleware()" error emitted a stray double space before its first bullet, so users saw - clerkMiddleware() is used in your Next.js middleware or proxy file. (two spaces after the dash).

In authAuthHeaderMissing, the first bullet's prefixSteps ternary fell back to ' ' (a single space) when prefixSteps was undefined — which is the getAuth() path. It's the only caller that passes undefined; auth() always passes an array (even an empty one, which is truthy), so it never hit this branch. Combined with the literal - already at the start of the line, the fallback produced a double space. This changes it to '' so that path renders - clerkMiddleware() is used... with a single space, matching the docs page for this error. The prefixSteps-provided branch (App Router src-directory hint) is unchanged.

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:

…rror

The default auth() case rendered "-  clerkMiddleware()..." with two spaces
because the prefixSteps ternary fell back to a single space combined with the
literal "- " prefix. Fall back to an empty string so the first bullet renders
with a single space, matching the docs.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: eaddce4

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

This PR includes changesets to release 1 package
Name Type
@clerk/nextjs Patch

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

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

@vercel

vercel Bot commented Aug 12, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview Aug 12, 2026 3:36am
swingset Ready Ready Preview Aug 12, 2026 3:36am

Request Review

@pkg-pr-new

pkg-pr-new Bot commented Aug 12, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/electron

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

@clerk/electron-passkeys

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

@clerk/eslint-plugin

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

@clerk/expo

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

@clerk/expo-google-signin

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/hono

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

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

@clerk/upgrade

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

@clerk/vue

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

commit: eaddce4

@coderabbitai

coderabbitai Bot commented Aug 12, 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: 94325c26-66e0-4627-a48d-bfc1116c1e4c

📥 Commits

Reviewing files that changed from the base of the PR and between a64d2ae and eaddce4.

📒 Files selected for processing (1)
  • .changeset/tidy-cameras-jump.md
🔗 Linked repositories identified

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

  • clerk/clerk_go (manual)
  • clerk/dashboard (manual)
  • clerk/accounts (manual)
  • clerk/backoffice (manual)
  • clerk/clerk (manual)
  • clerk/clerk-docs (manual)
  • clerk/cloudflare-workers (manual)
  • clerk/clerk-ios (auto-detected)
  • clerk/cli (auto-detected)
  • clerk/clerk-android (auto-detected)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/tidy-cameras-jump.md

📝 Walkthrough

Walkthrough

The authAuthHeaderMissing error message now omits the empty bullet-prefix line when prefixSteps is absent. A patch changeset documents the correction for @clerk/nextjs.

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

🚥 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 Next.js error-formatting fix and matches the main change.
Description check ✅ Passed The description accurately explains the double-space bug, the fallback change, and the preserved behavior.

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/nextjs/src/server/errors.ts (1)

27-27: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add a regression test for getAuthAuthHeaderMissing().

createGetAuth() uses this helper with undefined, which is the call path affected by the fallback change. The App Router auth() path passes [] and does not exercise the fallback.

🤖 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 `@packages/nextjs/src/server/errors.ts` at line 27, Add a regression test
covering getAuthAuthHeaderMissing() when invoked through createGetAuth() with
undefined prefixSteps, verifying the fallback-generated error message. Keep the
existing App Router auth() coverage separate, since its [] argument does not
exercise this fallback.
🤖 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.

Nitpick comments:
In `@packages/nextjs/src/server/errors.ts`:
- Line 27: Add a regression test covering getAuthAuthHeaderMissing() when
invoked through createGetAuth() with undefined prefixSteps, verifying the
fallback-generated error message. Keep the existing App Router auth() coverage
separate, since its [] argument does not exercise this fallback.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro Plus

Run ID: e1be75f3-bece-4c1f-a18b-e68765d43417

📥 Commits

Reviewing files that changed from the base of the PR and between 44edcc9 and a64d2ae.

📒 Files selected for processing (2)
  • .changeset/tidy-cameras-jump.md
  • packages/nextjs/src/server/errors.ts
🔗 Linked repositories identified

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

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

@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-08-12T03:36:33.691Z

Summary

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

No API Changes Detected

All packages have stable APIs with no detected changes.


Report generated by Break Check

Last ran on eaddce4.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant