Skip to content

Modern Docker Management, Designed for Everyone

fix: generic webhooks do not allow ports (#1517)

Kyle Mendell0cad203b8fa8
diff --git a/backend/internal/utils/notifications/generic_sender.go b/backend/internal/utils/notifications/generic_sender.go
index 3d40606e0..d79281a8b 100644
--- a/backend/internal/utils/notifications/generic_sender.go
+++ b/backend/internal/utils/notifications/generic_sender.go
@@ -23,6 +23,23 @@ func BuildGenericURL(config models.GenericConfig) (string, error) {
return "", fmt.Errorf("invalid webhook URL: %w", err)
}
+ hasScheme := strings.Contains(config.WebhookURL, "://")
+ if webhookURL.Host == "" && !hasScheme {
+ fallbackScheme := "https"
+ if config.DisableTLS {
+ fallbackScheme = "http"
+ }
+ normalized := strings.TrimPrefix(config.WebhookURL, "//")
+ webhookURL, err = url.Parse(fmt.Sprintf("%s://%s", fallbackScheme, normalized))
+ if err != nil {
+ return "", fmt.Errorf("invalid webhook URL: %w", err)
+ }
+ }
+
+ if webhookURL.Host == "" {
+ return "", fmt.Errorf("invalid webhook URL: missing host")
+ }
+
// Build generic service URL
// Format: generic://host[:port]/path?params
// Shoutrrr's generic service uses HTTP or HTTPS based on the DisableTLS setting
@@ -59,14 +76,15 @@ func BuildGenericURL(config models.GenericConfig) (string, error) {
query.Set("messagekey", config.MessageKey)
}
- // Determine TLS setting: respect both the original URL scheme and explicit config
- // If original URL was http:// OR DisableTLS is true → use HTTP (disabletls=yes)
- // Otherwise → use HTTPS (disabletls=no)
- disableTLS := config.DisableTLS || strings.ToLower(webhookURL.Scheme) == "http"
- if disableTLS {
+ // Determine TLS setting from the webhook URL scheme (http/https)
+ // If scheme is missing, DisableTLS is only used to infer the default scheme above.
+ switch strings.ToLower(webhookURL.Scheme) {
+ case "http":
query.Set("disabletls", "yes")
- } else {
+ case "https":
query.Set("disabletls", "no")
+ default:
+ return "", fmt.Errorf("invalid webhook URL scheme: %s", webhookURL.Scheme)
}
// Add custom headers as query parameters with @ prefix
diff --git a/backend/internal/utils/notifications/generic_sender_test.go b/backend/internal/utils/notifications/generic_sender_test.go
index c2ea71eff..037f03d2a 100644
--- a/backend/internal/utils/notifications/generic_sender_test.go
+++ b/backend/internal/utils/notifications/generic_sender_test.go
@@ -29,6 +29,28 @@ func TestBuildGenericURL(t *testing.T) {
},
wantURL: "generic://webhook.example.com/notify?disabletls=yes&template=json",
},
+ {
+ name: "webhook without scheme defaults to HTTPS",
+ config: models.GenericConfig{
+ WebhookURL: "webhook.example.com/notify",
+ },
+ wantURL: "generic://webhook.example.com/notify?disabletls=no&template=json",
+ },
+ {
+ name: "webhook without scheme with port",
+ config: models.GenericConfig{
+ WebhookURL: "webhook.example.com:8080/notify",
+ },
+ wantURL: "generic://webhook.example.com:8080/notify?disabletls=no&template=json",
+ },
+ {
+ name: "webhook without scheme with DisableTLS",
+ config: models.GenericConfig{
+ WebhookURL: "webhook.example.com/notify",
+ DisableTLS: true,
+ },
+ wantURL: "generic://webhook.example.com/notify?disabletls=yes&template=json",
+ },
{
name: "webhook with port",
config: models.GenericConfig{
@@ -62,12 +84,12 @@ func TestBuildGenericURL(t *testing.T) {
wantURL: "generic://webhook.example.com/notify?disabletls=no&messagekey=body&template=json&titlekey=subject",
},
{
- name: "webhook with DisableTLS",
+ name: "webhook with DisableTLS ignored for HTTPS",
config: models.GenericConfig{
WebhookURL: "https://webhook.example.com/notify",
DisableTLS: true,
},
- wantURL: "generic://webhook.example.com/notify?disabletls=yes&template=json",
+ wantURL: "generic://webhook.example.com/notify?disabletls=no&template=json",
},
{
name: "webhook with single custom header",
@@ -227,7 +249,7 @@ func TestBuildGenericURL_DisableTLSFlag(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
config := models.GenericConfig{
- WebhookURL: "https://webhook.example.com/notify",
+ WebhookURL: "webhook.example.com/notify",
DisableTLS: tt.disableTLS,
}
diff --git a/frontend/src/lib/types/notification-providers.ts b/frontend/src/lib/types/notification-providers.ts
index de6dc25e0..6fc2ebf4b 100644
--- a/frontend/src/lib/types/notification-providers.ts
+++ b/frontend/src/lib/types/notification-providers.ts
@@ -79,7 +79,6 @@ export interface GenericFormValues extends BaseProviderFormValues {
titleKey: string;
messageKey: string;
customHeaders: string;
- disableTls: boolean;
}
export interface AppriseFormValues {
@@ -355,7 +354,6 @@ export function genericSettingsToFormValues(settings?: NotificationSettings): Ge
titleKey: (cfg?.titleKey as string) || 'title',
messageKey: (cfg?.messageKey as string) || 'message',
customHeaders: customHeadersStr,
- disableTls: (cfg?.disableTls as boolean) ?? false,
eventImageUpdate: events?.image_update ?? true,
eventContainerUpdate: events?.container_update ?? true
};
@@ -414,7 +412,6 @@ export function genericFormValuesToSettings(values: GenericFormValues): Notifica
titleKey: values.titleKey,
messageKey: values.messageKey,
customHeaders: customHeaders,
- disableTls: values.disableTls,
events: {
image_update: values.eventImageUpdate,
container_update: values.eventContainerUpdate
diff --git a/frontend/src/routes/(app)/settings/notifications/providers/GenericProviderForm.svelte b/frontend/src/routes/(app)/settings/notifications/providers/GenericProviderForm.svelte
index 8000ffd59..fb1763476 100644
--- a/frontend/src/routes/(app)/settings/notifications/providers/GenericProviderForm.svelte
+++ b/frontend/src/routes/(app)/settings/notifications/providers/GenericProviderForm.svelte
@@ -7,8 +7,6 @@
import type { GenericFormValues } from '$lib/types/notification-providers';
import ProviderFormWrapper from './ProviderFormWrapper.svelte';
import EventSubscriptions from './EventSubscriptions.svelte';
- import { Checkbox } from '$lib/components/ui/checkbox';
- import { Label } from '$lib/components/ui/label';
interface Props {
values: GenericFormValues;
@@ -28,7 +26,6 @@
titleKey: z.string(),
messageKey: z.string(),
customHeaders: z.string(),
- disableTls: z.boolean(),
eventImageUpdate: z.boolean(),
eventContainerUpdate: z.boolean()
})
@@ -132,17 +129,6 @@
helpText={m.notifications_generic_custom_headers_help()}
/>
- <div class="flex items-center space-x-2">
- <Checkbox id="generic-disable-tls" bind:checked={values.disableTls} {disabled} />
- <Label
- for="generic-disable-tls"
- class="text-sm leading-none font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
- >
- {m.notifications_generic_disable_tls_label()}
- </Label>
- </div>
- <p class="text-muted-foreground -mt-1 text-xs">{m.notifications_generic_disable_tls_help()}</p>
-
<EventSubscriptions
providerId="generic"
bind:eventImageUpdate={values.eventImageUpdate}