fix: correct merged PR count in weekly summary and remove Playwright auth bypass#473
Merged
Priyanshu-byte-coder merged 3 commits intoMay 21, 2026
Conversation
The PR counting loop checked item.state === "closed" to determine a merge, but a PR can be closed without merging (rejected/abandoned). The GitHub search/issues response includes pull_request.merged_at which is non-null only for genuine merges. Updated the type and condition to use item.pull_request?.merged_at != null, so prsMergedThisWeek no longer inflates for closed-but-unmerged PRs. Fixes Priyanshu-byte-coder#451
dashboard/page.tsx used a client-settable cookie (playwright-dashboard-auth) combined with an env var (PLAYWRIGHT_AUTH_BYPASS=1) to let Playwright tests skip NextAuth. If the env var was accidentally set in production — a realistic Vercel misconfiguration — any user could access the dashboard by setting document.cookie = "playwright-dashboard-auth=1" in their browser. The e2e tests already inject a properly signed next-auth.session-token JWT (via next-auth/jwt encode()) using the same NEXTAUTH_SECRET as the dev server, so the cookie bypass was always redundant. Removed the bypass entirely: dashboard/page.tsx now calls getServerSession unconditionally, the redundant playwright-dashboard-auth cookie is dropped from the test setup, and PLAYWRIGHT_AUTH_BYPASS is removed from playwright.config.mjs. Tests continue to pass through the JWT-based auth path. Fixes Priyanshu-byte-coder#450
|
@advikdivekar is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel. A member of the Team first needs to authorize it. |
GSSoC Label Checklist 🏷️@Priyanshu-byte-coder — please apply the appropriate labels before merging: Difficulty (pick one):
Quality (optional):
Validation (required to score):
|
42b1789
into
Priyanshu-byte-coder:main
3 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #451, Closes #450
Two independent bugs fixed together — both are data-correctness or security issues with no new features.
Fix 1 — Weekly summary counts all closed PRs as merged (#451)
File:
src/app/api/metrics/weekly-summary/route.tsThe PR counting loop used
item.state === "closed"to decide whether a PR was merged. A PR can bestate: "closed"for two reasons: merged, orrejected/abandoned without merging. The GitHub search/issues response includes
pull_request.merged_atwhich isnullfor closed-but-not-mergedPRs. Updated the type and condition to use
item.pull_request?.merged_at != nullsoprsMergedThisWeekno longer inflates forclosed-but-unmerged PRs.
Fix 2 — Playwright auth bypass reachable in production (#450)
Files:
src/app/dashboard/page.tsx,e2e/dashboard-widgets.spec.js,playwright.config.mjsalternative to real NextAuth authentication. If that env var was accidentally deployed to production (a realistic Vercel misconfiguration), any
visitor could access the full dashboard by running
document.cookie = "playwright-dashboard-auth=1"in their browser.The e2e tests already inject a properly signed
next-auth.session-tokenJWT (vianext-auth/jwt encode()with the sameNEXTAUTH_SECRETas thedev server), so the cookie bypass was always redundant. Removed the bypass entirely:
dashboard/page.tsxnow callsgetServerSessionunconditionally, the redundant
playwright-dashboard-authcookie is dropped from the testbeforeEach, andPLAYWRIGHT_AUTH_BYPASSis removedfrom
playwright.config.mjs. Tests continue to pass through the JWT-based auth path.Test plan
#451 — Merged PR count
merged_atnon-null,state: "closed"→ counted inprsMergedThisWeekmerged_at: null,state: "closed"(rejected) → not counted inprsMergedThisWeekprsMergedThisWeekprsOpenedThisWeekcount is unaffected#450 — Auth bypass
grepconfirms zero remaining references toplaywright-dashboard-auth,PLAYWRIGHT_AUTH_BYPASS,allowPlaywrightBypass, orcookies()across all three files
dashboard/page.tsxcallsgetServerSessionunconditionally with no conditional bypassnext-auth.session-tokensigned JWT — auth works without the bypassnpm run lintandnpm run type-checkpass with zero errors