Fix/health endpoint abstraction, conditional TLS config, and git hook guard#84
Conversation
…ok guard Co-authored-by: DaTiC0 <13198638+DaTiC0@users.noreply.github.com>
|
@copilot DeepSource: Python |
There was a problem hiding this comment.
Pull request overview
This PR improves robustness around the app’s health check, MQTT TLS configuration, and developer tooling setup by centralizing MQTT connection status checks, avoiding TLS settings when TLS is disabled, and preventing git-hook install errors on fresh clones.
Changes:
- Added
is_mqtt_connected()helper innotifications.pyand updated/healthroute to use it. - Made
MQTT_TLS_VERSIONconditional onMQTT_TLS_ENABLED. - Guarded
chmod +xinscripts/install_git_hooks.shso it doesn’t fail when the hook file is missing.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| scripts/install_git_hooks.sh | Adds existence check before chmod’ing the pre-commit hook. |
| routes.py | Switches /health to use the new MQTT connection helper. |
| notifications.py | Introduces is_mqtt_connected() helper around MQTT client state. |
| config.py | Makes TLS version configuration conditional on TLS being enabled. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| from models import Client | ||
| from my_oauth import get_current_user, oauth | ||
| from notifications import mqtt | ||
| from notifications import mqtt, is_mqtt_connected |
There was a problem hiding this comment.
mqtt is imported but no longer used in this module after switching the /health route to is_mqtt_connected(). Dropping the unused import will avoid lint/tooling warnings and makes it clearer what this file depends on.
| from notifications import mqtt, is_mqtt_connected | |
| from notifications import is_mqtt_connected |
Co-authored-by: DaTiC0 <13198638+DaTiC0@users.noreply.github.com>
|
Fixed in Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
* Add health checks, workflow guards, and secure repo tooling * Document safe recovery for accidental main commits * Fix/health endpoint abstraction, conditional TLS config, and git hook guard (#84) * Initial plan * Address review feedback: MQTT helper, conditional TLS version, git hook guard Co-authored-by: DaTiC0 <13198638+DaTiC0@users.noreply.github.com> * Remove unused mqtt import from routes.py (fixes DeepSource F401) Co-authored-by: DaTiC0 <13198638+DaTiC0@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: DaTiC0 <13198638+DaTiC0@users.noreply.github.com> * Fix incorrect exit code 5 handling in Makefile unittest fallback (#87) * Initial plan * Fix incorrect exit code 5 handling in unittest block of Makefile Co-authored-by: DaTiC0 <13198638+DaTiC0@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: DaTiC0 <13198638+DaTiC0@users.noreply.github.com> * Use ssl.PROTOCOL_TLS_CLIENT for forward-compatible TLS negotiation (#86) * Initial plan * Use ssl.PROTOCOL_TLS_CLIENT instead of ssl.PROTOCOL_TLSv1_2 for TLS version negotiation Co-authored-by: DaTiC0 <13198638+DaTiC0@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: DaTiC0 <13198638+DaTiC0@users.noreply.github.com> * Defensive parsing of MQTT_BROKER_PORT env var (#85) * Initial plan * Add _get_int_env helper for safe MQTT_BROKER_PORT parsing Co-authored-by: DaTiC0 <13198638+DaTiC0@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: DaTiC0 <13198638+DaTiC0@users.noreply.github.com> --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: DaTiC0 <13198638+DaTiC0@users.noreply.github.com>
Summary
/healthendpoint accessedmqtt.connecteddirectly — fragile against internal attribute changes or unset state. Addedis_mqtt_connected()helper innotifications.py; health route now calls the helper instead, and the unusedmqttimport was removed fromroutes.py.MQTT_TLS_VERSIONwas set unconditionally tossl.PROTOCOL_TLSv1_2regardless of whether TLS was enabled. Now conditional onMQTT_TLS_ENABLED.install_git_hooks.shwould failchmod +xon a fresh clone without.githooks/pre-commit. Added existence guard.Validation
make test)make health)AI-Assisted Review (if applicable)
Risk & Rollback
c1fc041; no data or schema changes involved.✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.