-
Notifications
You must be signed in to change notification settings - Fork 1
322 validate config on initialisation #357
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
Conversation
- Introduce user-friendly error formatting for validation failures using `_format_validation_errors`. - Add robust validation logic for Slack settings with `@field_validator` for token prefixes. - Ensure all settings are initialized at import time, failing early if issues are encountered.
- Add handling for `error_type` to conditionally display provided values only when applicable. - Ensure robust formatting of validation error messages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds comprehensive configuration validation at application startup to reject invalid environment variables upfront with user-friendly error messages. The validation covers all SMIB_ environment variables except SMIB_PROXY_ and SMIB_COMPOSE_ prefixes.
- Adds field validators for Slack bot and app tokens to ensure proper formatting
- Implements centralized validation error collection and formatting in the config module
- Introduces fail-fast behavior that exits the application immediately on configuration errors
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/smib/config/slack.py | Adds token prefix validation for Slack bot and app tokens |
| src/smib/config/init.py | Implements configuration validation framework with error collection and user-friendly formatting |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
|
Changes done |
|
@sam57719 How do I test? I changed the name of the var and and the variable value in .env and rebuilt docker container and it built fine, what sort of errors does this catch and where does it show? |
|
This will validate the values of valid env vars. Any unknown env vars are ignored. The only 2 required ones are the 2 slack tokens. So for example, change the port to a alpha value, or set the log level to something invalid. Or omit one of the slack tokens. It doesn't validate things like the space open announce channel against slack. It's more the type of value thats validated. |
|
smib@smib-sj:~/git/smib $ docker logs -n 100 -f smib |
sjefferson99
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Container builds, spot check env vars are correctly logged as incorrect.
The config that is used by the Python app is now validated and rejected upfront if there are any errors.
This is all ENV VARS starting with
SMIB_apart fromSMIB_PROXY_andSMIB_COMPOSE_.Errors are formatted nicely with useful information.
Closes #322