constellation_utils.notifications¶
Slack notifications via chat.postMessage.
Stdlib-only. One public function :func:notify plus :class:SlackNotifyError
for the Slack-API quirk: chat.postMessage returns HTTP 200 even for
API-level failures, with {"ok": false, "error": "..."} in the body —
we parse and raise.
Auth: bot user OAuth token (xoxb-...) retrieved via
- func:
constellation_utils.secrets.slack_bot_token. Profile is required; no default at this layer (matches the secrets-module convention).
Module Contents¶
Functions¶
POST |
API¶
- exception constellation_utils.notifications.SlackNotifyError[source]¶
Bases:
RuntimeErrorRaised when
chat.postMessagereturnsok=falseor a body that isn’t valid UTF-8 JSON (e.g. an HTML error page from a WAF or transparent proxy in front ofslack.com).Non-2xx HTTP responses surface as :class:
urllib.error.HTTPErrorunchanged — they’re handled separately because they represent transport/auth problems rather than Slack API errors.Initialization
Initialize self. See help(type(self)) for accurate signature.
- add_note()¶
- class args¶
- with_traceback()¶
- constellation_utils.notifications.notify(message: str, *, level: Literal[info, warning, error], channel: str, profile: str) None[source]¶
POST
f"[{level}] {message}"to channel via Slackchat.postMessage.Blocks the caller for up to 10s on the HTTP POST. No retries and no exponential backoff — a 5xx surfaces as
urllib.error.HTTPError; a Slackok=falseresponse surfaces as :class:SlackNotifyError.level, channel, and profile are keyword-only with no default — matches the secrets-module convention. Per-package channel defaults (e.g. Virgo →
#virgo-status) are the caller’s responsibility.