Commit 1155b57e8a

1155b57e8a79d94dacc4689408b1ea48a29ce504

parent: fc527a7e38

Verified · cmc

cmc <hello@cleberg.net> · 2026-09-20 10:33 UTC

push: match scheme to the GITBAY_APNS_HOST override

NewClient hardcoded https, so a real gitbayd process could never
reach an e2e fake standing in for APNs: config.Push.Host already
redirects the host for tests, but the client still opened TLS
against it. A plain HTTP/1.1 fake answers with "server gave HTTP
response to HTTPS client", which Send treats as a retryable error,
so the push queue drains forever without ever delivering.

Drop the scheme with the host when the same override is set — it is
already documented as test-only, so production is unaffected.

Ref #89

Layout: unified · split

internal/push/apns.go +14 −1
@@ -8,6 +8,7 @@ import (
8 "fmt" 8 "fmt"
9 "io" 9 "io"
10 "net/http" 10 "net/http"
11 "os"
11 "strconv" 12 "strconv"
12 "strings" 13 "strings"
13 "time" 14 "time"
@@ -45,7 +46,7 @@ func NewClient(cfg config.Push) (*Client, error) {
45 // requires; no explicit http2 transport is needed. 46 // requires; no explicit http2 transport is needed.
46 http: &http.Client{Timeout: 30 * time.Second}, 47 http: &http.Client{Timeout: 30 * time.Second},
47 host: cfg.Host(), 48 host: cfg.Host(),
48 scheme: "https", 49 scheme: apnsScheme(),
49 topic: cfg.Topic, 50 topic: cfg.Topic,
50 } 51 }
51 if cfg.KeyFile != "" { 52 if cfg.KeyFile != "" {
@@ -59,6 +60,18 @@ func NewClient(cfg config.Push) (*Client, error) {
59 return c, nil 60 return c, nil
60} 61}
61 62
63// apnsScheme is https for the real Apple hosts. GITBAY_APNS_HOST redirects
64// the endpoint for tests (config.Push.Host), and the fake it points at
65// speaks plain HTTP/1.1 rather than negotiating TLS, so the same override
66// has to drop the scheme too, or every request fails with "server gave
67// HTTP response to HTTPS client" instead of reaching the fake at all.
68func apnsScheme() string {
69 if os.Getenv("GITBAY_APNS_HOST") != "" {
70 return "http"
71 }
72 return "https"
73}
74
62// Send delivers one alert. The returned duration is the server's 75// Send delivers one alert. The returned duration is the server's
63// Retry-After when it gave one, zero otherwise. 76// Retry-After when it gave one, zero otherwise.
64func (c *Client) Send(ctx context.Context, token, title, body, path string) (result, time.Duration, error) { 77func (c *Client) Send(ctx context.Context, token, title, body, path string) (result, time.Duration, error) {