Skip to content

Env var hygiene: PORTAL_BACKEND_URL missing from .env.example; DYNAMODB_STUDENT_REPORTS_TABLE_NAME unused #83

Description

@deepansh96

Two environment-variable inconsistencies found while documenting the codebase:

1. PORTAL_BACKEND_URL is required at import time but missing from .env.example

app/auth/__init__.py reads it with os.environ["PORTAL_BACKEND_URL"] at module import, so a missing value crashes the whole app at startup (KeyError), not with a 500 on first use. On Lambda this surfaces as API Gateway 502s on cold start.

It currently works locally only because of import order in app/main.py: internal.db (which calls load_dotenv("../.env.local")) is imported before the router that pulls in auth. Reordering imports would break startup.

Fix: add PORTAL_BACKEND_URL= to .env.example. Optionally, read the var lazily (inside the verify function) so startup doesn't depend on import order.

2. DYNAMODB_STUDENT_REPORTS_TABLE_NAME is defined but never used

It's listed in .env.example, but app/db/reports_db.py hard-codes both table names (student_quiz_reports, student_quiz_reports_v2).

Fix: either wire the wrapper to read table names from env (which would also unblock a real staging table), or drop the var from .env.example to stop suggesting it does something.

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions