fix(frontend): make profile URLs case-insensitive#485
Open
IvGolovach wants to merge 3 commits intojunhoyeo:mainfrom
Open
fix(frontend): make profile URLs case-insensitive#485IvGolovach wants to merge 3 commits intojunhoyeo:mainfrom
IvGolovach wants to merge 3 commits intojunhoyeo:mainfrom
Conversation
Validation - scripts/ledger/check: Not applicable - scripts/ledger/ does not exist in this repository. - git fetch --no-tags origin main: PASS - packages/frontend/node_modules/.bin/vitest run: PASS, 154 tests - bun run lint: PASS, 0 errors, 7 warnings in pre-existing unrelated files - bun run build: PASS - git diff --check: PASS - git diff --cached --check: PASS Rollback - git revert HEAD
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
3 issues found across 13 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/frontend/src/app/api/users/[username]/route.ts">
<violation number="1" location="packages/frontend/src/app/api/users/[username]/route.ts:32">
P1: Case-insensitive username lookup combined with `limit(1)` is ambiguous without a case-insensitive uniqueness guarantee, and may return the wrong user if case-variant duplicates exist.</violation>
</file>
<file name="packages/frontend/src/lib/leaderboard/getLeaderboard.ts">
<violation number="1" location="packages/frontend/src/lib/leaderboard/getLeaderboard.ts:507">
P2: Case-insensitive user lookup is not backed by case-insensitive uniqueness, so `.limit(1)` can return arbitrary users for case-colliding usernames and cache under a shared normalized key.</violation>
</file>
<file name="packages/frontend/src/lib/db/usernameLookup.ts">
<violation number="1" location="packages/frontend/src/lib/db/usernameLookup.ts:5">
P2: Case-insensitive username lookup uses LOWER(column) without a matching functional index, which can bypass the existing username index and degrade query performance.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Validation - scripts/ledger/check: Not applicable - scripts/ledger/ does not exist in this repository. - git fetch --no-tags origin main: PASS - packages/frontend/node_modules/.bin/vitest run __tests__/api/usersProfile.test.ts __tests__/lib/getLeaderboard.test.ts __tests__/lib/getLeaderboardAllTime.test.ts __tests__/lib/getUserEmbedStats.test.ts __tests__/lib/usernameLookup.test.ts: PASS, 23 tests - packages/frontend/node_modules/.bin/vitest run: PASS, 162 tests - bun run lint: PASS, 0 errors, 7 warnings in pre-existing unrelated files - bun run build: PASS - git diff --check: PASS - git diff --cached --check: PASS Rollback - git revert HEAD
Validation - scripts/ledger/check: Not applicable - scripts/ledger/ does not exist in this repository. - git fetch --no-tags origin main: PASS - packages/frontend/node_modules/.bin/vitest run __tests__/api/usersProfile.test.ts __tests__/lib/getLeaderboard.test.ts __tests__/lib/getLeaderboardAllTime.test.ts __tests__/lib/getUserEmbedStats.test.ts __tests__/lib/usernameLookup.test.ts: PASS, 24 tests - packages/frontend/node_modules/.bin/vitest run: PASS, 163 tests - bun run lint: PASS, 0 errors, 7 warnings in pre-existing unrelated files - bun run build: PASS - git diff --check: PASS - git diff --cached --check: PASS Rollback - git revert HEAD
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
Make profile username lookups case-insensitive across the frontend public profile surfaces.
Fixes #477.
Why
Shared profile URLs should resolve regardless of username casing. Before this change,
/u/imlunaheycould return not found while/u/ImLunaHeyworked, which made profile links unreliable and inconsistent with GitHub username expectations.Diff scope
packages/frontend/src/lib/db/usernameLookup.tswith shared case-insensitive username matching and cache-key normalization helpers.packages/frontend/src/app/api/users/[username]/route.tsto resolve profile usernames case-insensitively while returning the stored canonical username.packages/frontend/src/lib/embed/getUserEmbedStats.tsso embed stats and contribution lookups resolve usernames case-insensitively.packages/frontend/src/lib/leaderboard/getLeaderboard.tsso all-time and period user-rank lookups match usernames case-insensitively.packages/frontend/src/app/api/submit/route.tsandpackages/frontend/src/app/api/settings/submitted-data/route.tsso revalidation tags match the normalized cache keys.packages/frontend/__tests__/api/usersProfile.test.tspackages/frontend/__tests__/api/settingsSubmittedDataDelete.test.tspackages/frontend/__tests__/api/submitAuth.test.tspackages/frontend/__tests__/lib/getLeaderboard.test.tspackages/frontend/__tests__/lib/getLeaderboardAllTime.test.tspackages/frontend/__tests__/lib/getUserEmbedStats.test.tspackages/frontend/__tests__/lib/usernameLookup.test.tsBranch integrity
maingit rev-parse origin/main:edc8ed1fca49ec4a6936e4d4e15ca45dfd442b8egit rev-list --left-right --count origin/main...HEAD:0 101git merge-base origin/main HEAD:edc8ed1fca49ec4a6936e4d4e15ca45dfd442b8egit merge-base --is-ancestor origin/main HEAD: PASS, exit0origin/mainwith no divergence.Commit integrity
a6962fce4bff10798490d16c79a1aba2686382b2 fix(frontend): make profile username lookups case-insensitivescripts/ledger/does not exist in this repository.scripts/ledger/does not exist in this repository.Ledger proof
Not applicable —
scripts/ledger/does not exist in this repository.Diff hygiene
git diff --name-status origin/main...HEAD:git diff --check origin/main...HEAD: PASS, no output.envfiles, local environment files, secrets, tokens, credentials,ops/reports/**artifacts,__pycache__/,*.pyc,.DS_Store,.coverage,htmlcov/,coverage.xml, build artifacts, cache files, unrelated generated files, or unrelated source changes.Test proof
packages/frontend/node_modules/.bin/vitest run: PASS, 154 tests passed across 19 test filesbun run lint: PASS, 0 errors, 7 warnings in pre-existing unrelated filesbun run build: PASSVerification-pack proof
Not applicable — no infra/governance/replay/invariant/verification files changed.
Migration notes
Not applicable — no DB migration changed.
CI context confirmation
backend,frontend,simulated-correctness-coreRuntime safety
Reviewed runtime files/modules:
packages/frontend/src/app/api/users/[username]/route.tspackages/frontend/src/lib/embed/getUserEmbedStats.tspackages/frontend/src/lib/leaderboard/getLeaderboard.tspackages/frontend/src/app/api/submit/route.tspackages/frontend/src/app/api/settings/submitted-data/route.tspackages/frontend/src/lib/db/usernameLookup.tsRuntime reasoning:
Documentation integrity
Not applicable — no docs, runbooks, public commands, or operational behavior changed.
Rollback plan
git revert <post_merge_commit_sha><post_merge_commit_sha>with the final squash/merge commit SHA after merge.Known residual risks
LOWER(users.username)may not use the existing username unique index on every Postgres plan. No migration was added because this is a narrow single-user lookup; a functional index can be added later if profile lookup volume requires it.