Skip to content

fix(server-auth-actions): accept member-expression auth calls like auth0.getSession() (#239)#264

Closed
NisargIO wants to merge 2 commits into
fix/nextjs-get-handler-side-effects-206from
fix/server-auth-actions-member-call-239
Closed

fix(server-auth-actions): accept member-expression auth calls like auth0.getSession() (#239)#264
NisargIO wants to merge 2 commits into
fix/nextjs-get-handler-side-effects-206from
fix/server-auth-actions-member-call-239

Conversation

@NisargIO
Copy link
Copy Markdown
Member

Summary

Re-opens #261, which GitHub auto-closed after a force-push during rebase. Stacked on top of #263.

server-auth-actions only recognised auth calls when the callee was a bare Identifierauth(), getSession(), getUser(), etc. Every member-expression flavour (auth0.getSession(), supabase.auth.getSession(), clerkClient.getUser(userId), request.auth()) slipped through and the whole server action got flagged as missing an auth check. One reporter in #239 hit 139 false positives — essentially every server action in the repo.

Route every CallExpression through the existing getCalleeName utility, which already resolves both Identifier and MemberExpression callees to a single name. walkAst already descends into AwaitExpression / ChainExpression children, so awaited (await auth0.getSession()) and optional-chained (auth0?.getSession()) variants fall out for free with no extra branching.

This is more elegant than #240 (which adds a second else if branch duplicating the identifier check) and reuses code we already have.

Now accepted as an auth check

  • await auth0.getSession() — the verbatim repro
  • auth0.getSession() (non-awaited)
  • await supabase.auth.getSession() (chained member expression)
  • await clerkClient.getUser(userId)
  • await auth0?.getSession() (optional chaining)
  • await auth() / await getSession() (the original Identifier forms — still works)

Still flagged

  • Server actions with no auth-related call inside the first 10 statements.
  • Server actions calling unrelated .something() member methods.
  • Auth checks that happen after the lookahead window.

Test plan

  • Added packages/react-doctor/tests/regressions/server-auth-actions-member-call.test.ts with 6 false-negative cases and 3 true-positive cases.
  • nr typecheck, nr lint, nr test (918/918), nr format:check all pass.
  • Existing server-auth-actions regressions in packages/react-doctor/tests/run-oxlint/nextjs.test.ts still pass.

Closes #239. Supersedes #240.

Made with Cursor

NisargIO and others added 2 commits May 15, 2026 17:59
…uth0.getSession()` (#239)

`containsAuthCheck` only recognised auth calls with a bare `Identifier`
callee (`auth()`, `getSession()`, …), so every `auth0.getSession()`,
`supabase.auth.getSession()`, `clerkClient.getUser()` was missed and the
whole server action got flagged. One reporter hit 139 false positives —
essentially every server action in the repo.

Route every CallExpression through the existing `getCalleeName` utility,
which already resolves both Identifier and MemberExpression callees to a
single name. `walkAst` already descends into `AwaitExpression` /
`ChainExpression` children, so `await auth0.getSession()` and
`auth0?.getSession()` fall out for free with no extra branching.

Closes #239. Supersedes PR #240.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@reactreview
Copy link
Copy Markdown

reactreview Bot commented May 16, 2026

🔴 React Review0/100 (unchanged) · No new issues

Reviewed by react-review for commit 5bff156. Configure here.

@NisargIO NisargIO requested a review from aidenybai May 16, 2026 01:13
@vercel
Copy link
Copy Markdown

vercel Bot commented May 16, 2026

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

Project Deployment Actions Updated (UTC)
react-doctor-website Ready Ready Preview, Comment May 16, 2026 1:13am

@NisargIO NisargIO force-pushed the fix/nextjs-get-handler-side-effects-206 branch from 71ecf0a to bd9778a Compare May 16, 2026 01:18
@NisargIO
Copy link
Copy Markdown
Member Author

Closing in favor of reopened #261 (same diff, same branch).

@NisargIO NisargIO force-pushed the fix/server-auth-actions-member-call-239 branch from 3b9af6a to 5bff156 Compare May 16, 2026 01:19
@NisargIO NisargIO closed this May 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant