Conversation
WalkthroughIntroduces flexible Firebase credential loading from multiple sources with fallback support, adds configuration guards in authentication endpoints to require Firebase setup, refactors frontend authentication functions to return success/failure booleans instead of implicit navigation, and simplifies Vercel deployment configuration. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant Frontend as Frontend App
participant AuthCtx as Auth Context
participant Firebase as Firebase SDK
participant Backend as Backend API
User->>Frontend: Click Sign In with Google
activate Frontend
Frontend->>AuthCtx: SignInWithGoogle()
activate AuthCtx
Note over AuthCtx: Check Firebase config
alt Firebase not configured
AuthCtx->>Frontend: return false
Frontend->>User: Alert error
else Firebase configured
AuthCtx->>Firebase: Trigger Google sign-in
activate Firebase
Firebase->>User: Open Google dialog
User->>Firebase: Authenticate
Firebase->>AuthCtx: return user & ID token
deactivate Firebase
AuthCtx->>Backend: POST with ID token
activate Backend
alt Token valid
Backend->>AuthCtx: Verify & return success
AuthCtx->>Frontend: return true
else Token invalid
Backend->>AuthCtx: Verification failed
AuthCtx->>Frontend: return false
Frontend->>User: Alert error
end
deactivate Backend
alt Success
Frontend->>Frontend: Navigate to dashboard
end
end
deactivate AuthCtx
deactivate Frontend
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip Migrating from UI to YAML configuration.Use the |
@check-spelling-bot Report🔴 Please reviewSee the 📂 files view, the 📜action log, or 📝 job summary for details.Unrecognized words (26)These words are not needed and should be removedCRA leetcoderankingccps signupSome files were automatically ignored 🙈These sample patterns would exclude them: You should consider adding them to: File matching is via Perl regular expressions. To check these files, more of their words need to be in the dictionary than not. You can use To accept these unrecognized words as correct, update file exclusions, and remove the previously acknowledged and now absent words, you could run the following commands... in a clone of the git@github.com:VarshiniGunti/Leaderboard-Pro.git repository curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/main/apply.pl' |
perl - 'https://github.com/OpenLake/Leaderboard-Pro/actions/runs/23126784020/attempts/1' &&
git commit -m 'Update check-spelling metadata'Available 📚 dictionaries could cover words (expected and unrecognized) not in the 📘 dictionaryThis includes both expected items (592) from .github/actions/spelling/expect.txt and unrecognized words (26)
Consider adding them (in with:
extra_dictionaries: |
cspell:django/dict/django.txt
cspell:software-terms/dict/softwareTerms.txt
cspell:python/src/common/extra.txt
cspell:npm/dict/npm.txt
cspell:html/dict/html.txtTo stop checking additional dictionaries, add (in check_extra_dictionaries: ""Warnings
|
| Count | |
|---|---|
| 1 |
See
If you see a bunch of garbage
If it relates to a ...
well-formed pattern
See if there's a pattern that would match it.
If not, try writing one and adding it to the patterns.txt file.
Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.
Note that patterns can't match multiline strings.
binary-ish string
Please add a file path to the excludes.txt file instead of just accepting the garbage.
File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.
^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).
There was a problem hiding this comment.
🧹 Nitpick comments (4)
app/src/Context/AuthContext.jsx (2)
219-225: Dead code:response["status"] === 400check is never true.
signInWithPopupreturns aUserCredentialobject on success or throws an exception on failure. It never returns an object with astatusproperty. The condition!(response["status"] === 400)will always be true for successful responses, making this check ineffective.Consider simplifying to just check for the response and user:
♻️ Proposed simplification
response = await signInWithPopup(auth, googleProvider); - if (response && !(response["status"] === 400)) { + if (response?.user) { const idToken = await response.user.getIdToken();🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/src/Context/AuthContext.jsx` around lines 219 - 225, Remove the dead status check on the signInWithPopup result: signInWithPopup(auth, googleProvider) returns a UserCredential or throws, so delete the invalid response["status"] === 400 logic and instead verify the returned object and its user property (e.g., check that response and response.user exist) before calling response.user.getIdToken(); update the conditional around signInWithPopup to handle success by checking response && response.user and rely on try/catch to handle failures.
264-270: Same dead code issue asSignInWithGoogle.The
response["status"] === 400check is ineffective here as well.♻️ Proposed simplification
response = await signInWithPopup(auth, googleProvider); - if (response && !(response["status"] === 400)) { + if (response?.user) { const idToken = await response.user.getIdToken();🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/src/Context/AuthContext.jsx` around lines 264 - 270, Remove the ineffective response["status"] === 400 check in the Google sign-in flow and instead validate the actual sign-in result and user object returned by signInWithPopup; specifically, in the code using signInWithPopup(auth, googleProvider) check that response and response.user exist (and that response.user.getIdToken() returns a token), and handle failures via the existing try/catch path rather than testing a non-existent HTTP status on the response object (references: signInWithPopup, googleProvider, response.user.getIdToken).api/leaderboard/api/firebase.py (1)
31-35: Add logging when Firebase initialization fails.The broad
except Exceptioncatch prevents startup crashes, which is appropriate for optional Firebase support. However, silently swallowing all exceptions makes debugging difficult when credentials are misconfigured.🔧 Proposed fix to add diagnostic logging
+import logging + +logger = logging.getLogger(__name__) + try: cred = _load_credentials() default_app = firebase_admin.initialize_app(cred) if cred else None + if default_app is None: + logger.warning("Firebase Admin SDK not initialized: no credentials found") -except Exception: +except Exception as e: + logger.exception("Firebase Admin SDK initialization failed: %s", e) default_app = None🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@api/leaderboard/api/firebase.py` around lines 31 - 35, The try/except around _load_credentials() and firebase_admin.initialize_app currently swallows all exceptions; update the except block to catch Exception as e and log a clear diagnostic using the existing logger (or create one) that includes the exception details and context (e.g., "Failed to initialize Firebase app with credentials") and still assign default_app = None; reference _load_credentials, firebase_admin.initialize_app, and default_app so you modify that exact initialization block.api/vercel.json (1)
2-14: Celery worker deployment removed — ensure workers run elsewhere.The simplified configuration removes any Celery worker build/route entries. However,
api/leaderboard/settings.py(lines 250-281) still definesCELERY_BEAT_SCHEDULEwith 5 periodic tasks (codechef, github, leetcode, openlake, codeforces updates). These tasks will be scheduled but never executed unless Celery workers are deployed on separate infrastructure outside Vercel.If Celery is intentionally disabled for now, consider commenting out or removing the
CELERY_BEAT_SCHEDULEconfiguration to avoid confusion. If workers are expected to run elsewhere, document the required deployment setup.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@api/vercel.json` around lines 2 - 14, The Vercel config removes Celery worker deployment but the app still defines CELERY_BEAT_SCHEDULE in leaderboard/settings.py with periodic tasks (codechef_update, github_update, leetcode_update, openlake_update, codeforces_update); update the repo to either remove or comment out the CELERY_BEAT_SCHEDULE block if Celery is intentionally disabled, or add a short README note and deployment docs indicating that Celery workers must run on separate infrastructure and how to deploy/start them (including broker/worker service and beat), so the scheduled tasks are either disabled or clearly documented to run elsewhere.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@api/leaderboard/api/firebase.py`:
- Around line 31-35: The try/except around _load_credentials() and
firebase_admin.initialize_app currently swallows all exceptions; update the
except block to catch Exception as e and log a clear diagnostic using the
existing logger (or create one) that includes the exception details and context
(e.g., "Failed to initialize Firebase app with credentials") and still assign
default_app = None; reference _load_credentials, firebase_admin.initialize_app,
and default_app so you modify that exact initialization block.
In `@api/vercel.json`:
- Around line 2-14: The Vercel config removes Celery worker deployment but the
app still defines CELERY_BEAT_SCHEDULE in leaderboard/settings.py with periodic
tasks (codechef_update, github_update, leetcode_update, openlake_update,
codeforces_update); update the repo to either remove or comment out the
CELERY_BEAT_SCHEDULE block if Celery is intentionally disabled, or add a short
README note and deployment docs indicating that Celery workers must run on
separate infrastructure and how to deploy/start them (including broker/worker
service and beat), so the scheduled tasks are either disabled or clearly
documented to run elsewhere.
In `@app/src/Context/AuthContext.jsx`:
- Around line 219-225: Remove the dead status check on the signInWithPopup
result: signInWithPopup(auth, googleProvider) returns a UserCredential or
throws, so delete the invalid response["status"] === 400 logic and instead
verify the returned object and its user property (e.g., check that response and
response.user exist) before calling response.user.getIdToken(); update the
conditional around signInWithPopup to handle success by checking response &&
response.user and rely on try/catch to handle failures.
- Around line 264-270: Remove the ineffective response["status"] === 400 check
in the Google sign-in flow and instead validate the actual sign-in result and
user object returned by signInWithPopup; specifically, in the code using
signInWithPopup(auth, googleProvider) check that response and response.user
exist (and that response.user.getIdToken() returns a token), and handle failures
via the existing try/catch path rather than testing a non-existent HTTP status
on the response object (references: signInWithPopup, googleProvider,
response.user.getIdToken).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 78af3d2c-4046-4bdf-9414-e3be06343cd9
📒 Files selected for processing (6)
api/leaderboard/api/firebase.pyapi/leaderboard/api/views.pyapi/vercel.jsonapp/src/Context/AuthContext.jsxapp/src/components/Login.jsxapp/src/components/Register.jsx
|
LGTM. |
Description
This PR fixes deployment and authentication blockers that prevented testing PRs.
It removes invalid backend Vercel function config and fixes Google auth token handling so login/register works reliably in deployed environments.
Related Issue(s)
Changes
/api/token/google/and/api/register/google/).FIREBASE_SERVICE_ACCOUNT/FIREBASE_SERVICE_ACCOUNT_PATH) with local fallback.Screenshots of relevant screens 📸
None
Type of Change
Checklist
Notes
manage.py checkcould not complete in local environment due topsycopgruntime dependency issue, not due to this PR.service-account.json.Summary by CodeRabbit
Release Notes
Bug Fixes
New Features