fix: replace remaining runtime asserts with explicit ValueError checks#260
fix: replace remaining runtime asserts with explicit ValueError checks#260nightcityblade wants to merge 2 commits into
Conversation
|
I dont think it makes sense to do #249 partially, it is cleaner if we have a single PR that fixes it fully. |
|
Precisely the asserts located in the |
|
That's a fair point — since the config checks run at startup before the app is live, |
|
just reset your last commit and continue with the fix, please |
|
@nightcityblade what's the status of this? |
072a7c4 to
53fca55
Compare
|
Thanks for the nudge. I reset the earlier partial direction and expanded the fix to cover the remaining runtime What I updated in the amended commit:
Tests run:
|
alvaro-mazcu
left a comment
There was a problem hiding this comment.
Remember to change the PR name after the changes, @nightcityblade
There was a problem hiding this comment.
Rollback the changes in this file, as they are executed before the app is running
|
@nightcityblade Check also the pre-commit error |
|
Good catch, thanks. I pushed the Black formatting changes from the failing pre-commit run, so the hook should be green on the next pass. |
Fixes #249 (partial — config.py)
Replaces all 7
assertstatements inapp/config.py:initialize_settings()with explicitif not ...: raise ValueError(...)checks.Why this matters: These asserts validate required environment variables (Meta API keys, WhatsApp tokens, database URL) at startup. Under
python -O,assertstatements are stripped entirely, meaning the app would start with missing credentials and fail later with confusing errors.What changed:
assert (condition), "message"→if not (condition): raise ValueError("message")The remaining ~25 asserts in service files can be addressed in a follow-up PR.