Skip to content

Commit 1eec029

Browse files
committed
Use TLS by default as a client, log when PR URLs are missing
1 parent 7c24ae4 commit 1eec029

3 files changed

Lines changed: 17 additions & 7 deletions

File tree

cmd/client/main.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ func gitHubToken(flagToken string) (string, error) {
5757

5858
func run() error {
5959
var (
60-
serverAddr = flag.String("addr", "localhost:8080", "server address")
60+
serverAddr = flag.String("addr", client.DefaultServerAddress, "server address (hostname:port)")
6161
org = flag.String("org", "", "GitHub organization to subscribe to (use '*' for all your orgs)")
6262
token = flag.String("token", "", "GitHub personal access token")
6363
userEvents = flag.Bool("user", false, "Subscribe to your events across all organizations")
6464
eventTypes = flag.String("events", "", "Comma-separated list of event types to subscribe to (use '*' for all)")
6565
prs = flag.String("prs", "", "Comma-separated list of PR URLs to subscribe to (max 200)")
66-
useTLS = flag.Bool("tls", false, "Use TLS (wss://)")
66+
insecure = flag.Bool("insecure", false, "Use insecure WebSocket (ws:// instead of wss://)")
6767
verbose = flag.Bool("verbose", false, "Show full event details")
6868
noReconnect = flag.Bool("no-reconnect", false, "Disable automatic reconnection")
6969
maxRetries = flag.Int("max-retries", 0, "Maximum reconnection attempts (0 = infinite)")
@@ -104,10 +104,11 @@ func run() error {
104104
return err
105105
}
106106

107-
// Build WebSocket URL
108-
scheme := "ws"
109-
if *useTLS {
110-
scheme = "wss"
107+
// Build WebSocket URL - secure by default
108+
scheme := "wss"
109+
if *insecure {
110+
scheme = "ws"
111+
log.Println("WARNING: Using insecure WebSocket connection (ws://)")
111112
}
112113
url := fmt.Sprintf("%s://%s/ws", scheme, *serverAddr)
113114

pkg/client/client.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ func (e *AuthenticationError) Error() string {
2626
}
2727

2828
const (
29+
// DefaultServerAddress is the default webhook sprinkler server address.
30+
DefaultServerAddress = "webhook.github.codegroove.app"
31+
2932
// UI constants for logging.
3033
separatorLine = "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
3134
msgTypeField = "type"

pkg/webhook/handler.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,13 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
137137
// Extract PR URL
138138
prURL := ExtractPRURL(eventType, payload)
139139
if prURL == "" {
140-
log.Printf("no PR URL found in %s event", eventType)
140+
// Log full payload to understand the structure
141+
payloadJSON, _ := json.MarshalIndent(payload, "", " ")
142+
logger.Info("no PR URL found in event - full payload", logger.Fields{
143+
"event_type": eventType,
144+
"delivery_id": deliveryID,
145+
"payload": string(payloadJSON),
146+
})
141147
w.WriteHeader(http.StatusOK)
142148
return
143149
}

0 commit comments

Comments
 (0)