Skip to content

bug: Duplicate _unique_google_username function definition in auth.py causes silent dead code #786

Description

@NaitikVerma6776

🐛 Bug Description

backend/app/routes/auth.py defines the helper function
_unique_google_username twice in the same module:

  • First definition: line 166
  • Second definition: line 682

Python silently uses the last definition when a function is defined twice — meaning the first definition at line
166 is dead code that is never actually executed, despite appearing to be valid and active code.

📍 Where it happens

File: backend/app/routes/auth.py

# Line 166 — DEAD CODE (never executed)
def _unique_google_username(email: str, db: Session) -> str:
    ...

# Line 309 — calls the function (resolves to line 682)
username = _unique_google_username(email, db)

# Line 682 — actual definition Python uses at runtime
def _unique_google_username(email: str, db: Session) -> str:
    ...

# Line 971 — calls the function (resolves to line 682)
username = _unique_google_username(email, db)

⚠️ Why This Is a Problem

If a developer edits the first definition (line 166) assuming it's the active one, their change will have
zero effect at runtime — Python silently ignores it. The two definitions could also silently diverge over
time, creating confusing and hard-to-debug behaviour.

✅ Proposed Fix

Remove the first (duplicate) definition at line 166, keeping only the second definition at line 682 which
is what Python was already using at runtime.

No logic changes required — purely dead code removal.

📁 Files to Change

  • backend/app/routes/auth.py — remove first definition

🤝 GSSoC '26

  • Yes, I am participating in GirlScript Summer of
    Code and would like to fix this.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or improvementgssocGirlScript Summer of Code 2026 issue/PR

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions