Skip to content

Fix: Add Validation for Environment Variables in config.py#10

Open
kunalbhardwaj2006 wants to merge 1 commit into
mainfrom
fix/config-env-validation
Open

Fix: Add Validation for Environment Variables in config.py#10
kunalbhardwaj2006 wants to merge 1 commit into
mainfrom
fix/config-env-validation

Conversation

@kunalbhardwaj2006
Copy link
Copy Markdown
Owner

This PR improves configuration safety by validating environment variables in config.py.

Changes:

  • Added helper functions to safely parse integer and float environment variables.
  • Added validation for IMAGE_FORMAT to ensure only 'png' or 'webp' are allowed.
  • Added range validation for IMAGE_QUALITY (1–100).
  • Replaced assert with explicit validation for CLASSIFICATION_BATCH_SIZE.
  • Added validation for PDF_ZOOM_LEVEL to ensure positive values.

These improvements prevent misconfiguration and provide clearer error messages when environment variables contain invalid values.

@kunalbhardwaj2006
Copy link
Copy Markdown
Owner Author

Hi maintainers 👋

I noticed that some environment variables in config.py were being parsed directly using int() and assert, which could lead to unclear errors if invalid values are provided.

This PR adds validation and safe parsing helpers to improve configuration robustness and provide clearer error messages.

Happy to adjust if there is a preferred configuration pattern in the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant