Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logic when environment variables do not exist #307

Open
maxachis opened this issue May 27, 2024 · 2 comments
Open

Add logic when environment variables do not exist #307

maxachis opened this issue May 27, 2024 · 2 comments
Labels
enhancement New feature or request in_dev This is merged into the dev environment and waiting to be merged into main python Pull requests that update Python code

Comments

@maxachis
Copy link
Contributor

maxachis commented May 27, 2024

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.

@maxachis maxachis added enhancement New feature or request python Pull requests that update Python code labels May 27, 2024
@josh-chamberlain
Copy link
Contributor

@maxachis I'd say the app doesn't need to function appropriately without environment variables; we could just throw an error and tell people they're required.

@maxachis
Copy link
Contributor Author

@maxachis I'd say the app doesn't need to function appropriately without environment variables; we could just throw an error and tell people they're required.

@josh-chamberlain Oh, of course: What I meant was it we should test that it functions appropriately by throwing and error and telling people they're required.

@maxachis maxachis added the in_dev This is merged into the dev environment and waiting to be merged into main label Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request in_dev This is merged into the dev environment and waiting to be merged into main python Pull requests that update Python code
Projects
None yet
Development

No branches or pull requests

2 participants