fix: skip response.headers.set() in GET handler side-effect check (#206)
Summary
Fixes a false positive in nextjsNoSideEffectInGetHandler where response.headers.set() was flagged as a side effect in GET route handlers.
Setting response headers is a legitimate and expected operation in Next.js GET route handlers — it does not represent a CSRF-vulnerable write. This PR adds an isHeadersChainCall helper that excludes .headers.set() (and any .headers.*() mutation) from the DB mutation check in findSideEffect.
Closes #206
[!NOTE] Low Risk Low risk: small, localized change to AST side-effect detection logic to reduce false positives, with minimal impact outside GET-handler lint diagnostics.
Overview Prevents
nextjsNoSideEffectInGetHandler(and other rules usingfindSideEffect) from flaggingresponse.headers.*()calls as “DB mutations” in GET handlers.Adds an
isHeadersChainCallAST helper and uses it to exclude any call whose member chain includes.headersfrom theisMutatingDbCallbranch infindSideEffect, fixing theresponse.headers.set()false positive.Reviewed by Cursor Bugbot for commit cc441af1d44e66e404d79496f747219dd08c6da2. Bugbot is set up for automated code reviews on this repo. Configure here.
[!NOTE] No issues found
@PranavAgarkar07 is attempting to deploy a commit to the Million Team on Vercel.
A member of the Team first needs to authorize it.
Working on a related fix in #260 that takes a slightly broader angle — covers .headers chains (your isHeadersChainCall shape), locally-scoped Map/Set/Headers/URLSearchParams/FormData bindings, .searchParams, aliased headers(), cron routes, and depth-bounded handler resolution for export const GET = withAuth(handler) patterns. Thanks for the report — your repro and test cases were super useful while validating the broader fix.