(bugfix) Allow blank notification webhook headers

Normalize blank notification webhook headers to an empty JSON object so creating email targets from the browser does not try to store NULL in the JSON field.

Closes #95
This commit is contained in:
Codex
2026-06-08 22:23:03 +02:00
parent 51142081c9
commit ac0cdb59d6
2 changed files with 25 additions and 0 deletions

View File

@@ -318,6 +318,27 @@ class ViewTests(TestCase):
self.assertEqual(target.channel, NotificationTarget.Channel.EMAIL)
self.assertEqual(target.statuses, [BackupRun.Status.FAILED, BackupRun.Status.WARNING])
self.assertEqual(target.email_to, "ops@example.test\nbackup@example.test")
self.assertEqual(target.webhook_headers, {})
def test_notification_target_form_allows_blank_webhook_headers(self) -> None:
self.client.force_login(self.staff_user)
response = self.client.post(
reverse("create_notification_target"),
{
"name": "ops",
"enabled": "on",
"channel": NotificationTarget.Channel.EMAIL,
"statuses": [BackupRun.Status.FAILED],
"email_to": "ops@example.test",
"webhook_headers": "",
},
follow=True,
)
self.assertRedirects(response, reverse("notification_targets"))
target = NotificationTarget.objects.get(name="ops")
self.assertEqual(target.webhook_headers, {})
def test_notification_target_form_requires_channel_destination(self) -> None:
self.client.force_login(self.staff_user)