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

notify

POST f"[{level}] {message}" to channel via Slack chat.postMessage.

API

exception constellation_utils.notifications.SlackNotifyError[source]

Bases: RuntimeError

Raised when chat.postMessage returns ok=false or a body that isn’t valid UTF-8 JSON (e.g. an HTML error page from a WAF or transparent proxy in front of slack.com).

Non-2xx HTTP responses surface as :class:urllib.error.HTTPError unchanged — 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 Slack chat.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 Slack ok=false response 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.