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

Implement Standardized Environment Variable Validation #3

Open
k-allagbe opened this issue Sep 15, 2023 · 7 comments
Open

Implement Standardized Environment Variable Validation #3

k-allagbe opened this issue Sep 15, 2023 · 7 comments

Comments

@k-allagbe
Copy link
Member

Description

The goal is to standardize the way we validate environment variables and configurations.

We need to implement a solution that performs this validation for all critical environment variables, checking aspects such as type, format (e.g., regex for URLs, email addresses), presence of required variables, etc.

Acceptance Criteria

  1. All critical environment variables should be validated before the server or application starts.
  2. The validation should support various data types (string, integer, boolean, etc.).
  3. Regular expressions should be used to validate variables like URLs and email addresses.
  4. The solution should halt the application start-up if invalid environment variables are detected.

Notes

  • This validation should happen as early as possible during the application initialization to prevent any invalid configuration from affecting the system.
@k-allagbe k-allagbe added the enhancement New feature or request label Sep 15, 2023
@rngadam
Copy link

rngadam commented Sep 20, 2023

How I envision it:

a declarative solution with an env.yml that:

  • contains the list of environment variables to be validated
    • and for each environment variable
      • their type (email, number, etc)
      • if they are optional or not
      • if they can be empty
      • optional validation using regexp

I would be astonished if this functionality didn't already exist as an opensource python library somewhere so some research is in order.

@rngadam rngadam transferred this issue from ai-cfia/membrane-backend Sep 26, 2023
@k-allagbe k-allagbe moved this to Todo in Membrane Sep 27, 2023
@k-allagbe k-allagbe moved this from Todo to In Progress in Membrane Oct 4, 2023
@k-allagbe
Copy link
Member Author

The closest tool i could find is datamodel_code_generator. But it is a command line tool. I could try and create our own tool for this, based on Pydantic.

@k-allagbe k-allagbe moved this from In Progress to Todo in Membrane Oct 5, 2023
@rngadam
Copy link

rngadam commented Oct 5, 2023

@k-allagbe please outline a bit more of how it would look like with Pydantic

@k-allagbe
Copy link
Member Author

@rngadam ai-cfia/membrane-backend@adc4410
A drawback is that the yaml file would follow Pydantic's constraints naming. It would not be language agnostic.

@rngadam
Copy link

rngadam commented Oct 5, 2023

@k-allagbe best that you can a Draft PR so I can start commenting on it early.

are we also able to integrate text description for each field and links to references for the doc? and generate configuration documentation from the env.yaml?

@k-allagbe
Copy link
Member Author

@rngadam ai-cfia/membrane-backend#78
There is a description field available for that indeed. It would look like this:

MEMBRANE_FRONTEND:
  type: str
  field_info:
    default: http://localhost:3000
    description: <desc>

@rngadam
Copy link

rngadam commented Oct 9, 2023

ok, but my concern is we decided to both document 1) a description of the field and 2) a link to the dependency documentation. are we able to integrate both here with a single description field?

@k-allagbe k-allagbe moved this from Todo to In Progress in Membrane Oct 16, 2023
@k-allagbe k-allagbe removed their assignment Dec 21, 2023
@ThomasCardin ThomasCardin moved this to Todo in DevSecOps Jan 3, 2024
@ThomasCardin ThomasCardin removed the enhancement New feature or request label Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Status: In Progress
Development

No branches or pull requests

3 participants