Per-type channel config validation + defensive notifier parsing + schema length caps #55

Closed
opened 2026-07-18 05:31:20 +00:00 by claude-bot · 1 comment
Contributor

_validate_channel_config (app/api/channels.py:52-60) validates only webhook
and sms. Discord int(config["channel_id"]) (discord_bot.py:78 et al.),
Pushover int(priority) (pushover.py:70), and webhook method.upper() /
{**headers} before the try block (webhook.py:140-142) all crash on
malformed stored config — at send time, on every send. Schemas also lack
max_length mirroring String(128) columns (DataError → 500 instead of 422).

Scope: per-type Pydantic config models (discriminated on type) applied at
create/update; defensive parsing in notifiers (clear "bad config" log +
delivery record, not a stack trace); max_length on Create/Update string
fields. Scheduled with v1.2.0 since #14's formatter migration touches every
notifier anyway; the secret-redaction issue (F-08) should land its read-side
changes first.

Acceptance criteria:

  • Creating a discord/pushover/webex/matrix/signal channel with malformed config returns 422
  • Malformed legacy config produces a logged "bad config" delivery failure, not a crash
  • String fields enforce DB-matching max lengths

Filed from the 2026-07-17 codebase audit (docs/.internal/report-2026-07-17.md), finding F-16.

`_validate_channel_config` (app/api/channels.py:52-60) validates only webhook and sms. Discord `int(config["channel_id"])` (discord_bot.py:78 et al.), Pushover `int(priority)` (pushover.py:70), and webhook `method.upper()` / `{**headers}` before the try block (webhook.py:140-142) all crash on malformed stored config — at send time, on every send. Schemas also lack `max_length` mirroring `String(128)` columns (DataError → 500 instead of 422). Scope: per-type Pydantic config models (discriminated on `type`) applied at create/update; defensive parsing in notifiers (clear "bad config" log + delivery record, not a stack trace); `max_length` on Create/Update string fields. Scheduled with v1.2.0 since #14's formatter migration touches every notifier anyway; the secret-redaction issue (F-08) should land its read-side changes first. **Acceptance criteria:** - [ ] Creating a discord/pushover/webex/matrix/signal channel with malformed config returns 422 - [ ] Malformed legacy config produces a logged "bad config" delivery failure, not a crash - [ ] String fields enforce DB-matching max lengths --- _Filed from the 2026-07-17 codebase audit (`docs/.internal/report-2026-07-17.md`), finding F-16._
Author
Contributor

Done in #99 (merged). Per-type Pydantic config models now validate discord/matrix/pushover/webex/signal config at create/update (malformed → 422, not a later send-time crash), added alongside the existing webhook/sms validators. The notifiers gained defensive parsing at the bare-int()/attribute-access points (discord channel_id, pushover priority, webhook method/headers) so malformed legacy config records a clear delivery failure instead of crashing. Create/Update name fields gained max_length caps mirroring the String(128) columns (overlong → 422 instead of a 500 DataError).

Done in #99 (merged). Per-type Pydantic config models now validate discord/matrix/pushover/webex/signal config at create/update (malformed → 422, not a later send-time crash), added alongside the existing webhook/sms validators. The notifiers gained defensive parsing at the bare-`int()`/attribute-access points (discord channel_id, pushover priority, webhook method/headers) so malformed *legacy* config records a clear delivery failure instead of crashing. Create/Update name fields gained `max_length` caps mirroring the `String(128)` columns (overlong → 422 instead of a 500 DataError).
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rbrooks/WeatherBot#55
No description provided.