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
internal/push/apns.go +14 −1
@@ -8,6 +8,7 @@ import (
88 "fmt"
99 "io"
1010 "net/http"
11 "os"
1112 "strconv"
1213 "strings"
1314 "time"
@@ -45,7 +46,7 @@ func NewClient(cfg config.Push) (*Client, error) {
4546 // requires; no explicit http2 transport is needed.
4647 http: &http.Client{Timeout: 30 * time.Second},
4748 host: cfg.Host(),
48 scheme: "https",
49 scheme: apnsScheme(),
4950 topic: cfg.Topic,
5051 }
5152 if cfg.KeyFile != "" {
@@ -59,6 +60,18 @@ func NewClient(cfg config.Push) (*Client, error) {
5960 return c, nil
6061}
6162
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
6275// Send delivers one alert. The returned duration is the server's
6376// Retry-After when it gave one, zero otherwise.
6477func (c *Client) Send(ctx context.Context, token, title, body, path string) (result, time.Duration, error) {