Skip to content

Add logic when environment variables do not exist #307

Closed
Police-Data-Accessibility-Project/data-sources-app-v2-archive
#50
@maxachis

Description

@maxachis

There are several cases where an environmental variable is pulled but where no clear error is thrown when the environmental variable is not provided.

For example, login_queries.py:

def create_session_token(cursor: PgCursor, user_id: int, email: str) -> str:
    """
    Generates a session token for a user and inserts it into the session_tokens table.
    ....
    """
    # ...
    session_token = jwt.encode(payload, os.getenv("SECRET_KEY"), algorithm="HS256")
    # ...

This can cause confusion, especially for developers, who will have to dig into the code to find out that the cause of an error is a missing environmental variable.

Tests should additionally be added to ensure the app functions appropriately when environmental variables are not provided.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement 👑New feature or requestpython 🐍Pull requests that update Python code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions