debug: add panic recovery and verbose logging to processOutbound
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Adds per-step log entries so we can trace exactly where the outbound SMS flow breaks: goroutine start, phone normalization result, Cast API call attempt, and Cast API result. Also adds panic recovery so a crash in the goroutine is captured in structured logs instead of lost silently. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
parent
b01b0f703c
commit
3ea663c8dc
@ -120,9 +120,17 @@ func (h *WebhookHandler) HandleWebhook(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func (h *WebhookHandler) processOutbound(webhook OutboundMessageWebhook) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
slog.Error("webhook: processOutbound panic", "message_id", webhook.MessageID, "panic", r)
|
||||
}
|
||||
}()
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
slog.Info("webhook: processing outbound SMS", "message_id", webhook.MessageID, "location_id", webhook.LocationID, "phone", webhook.Phone)
|
||||
|
||||
localPhone, err := phone.ToLocal(webhook.Phone)
|
||||
if err != nil {
|
||||
slog.Error("webhook: phone normalization failed", "phone", webhook.Phone, "err", err)
|
||||
@ -130,9 +138,10 @@ func (h *WebhookHandler) processOutbound(webhook OutboundMessageWebhook) {
|
||||
return
|
||||
}
|
||||
|
||||
slog.Info("webhook: calling cast api", "message_id", webhook.MessageID, "to", localPhone)
|
||||
_, err = h.castClient.SendSMS(ctx, localPhone, webhook.Message)
|
||||
if err != nil {
|
||||
slog.Error("webhook: cast send failed", "message_id", webhook.MessageID, "err", err)
|
||||
slog.Error("webhook: cast send failed", "message_id", webhook.MessageID, "to", localPhone, "err", err)
|
||||
h.updateStatus(ctx, webhook, "failed")
|
||||
return
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user