{"record":{"id":"685453a5896f022f","repo":"sipeed/picoclaw","slug":"teams-webhook-send-failed-w","errorCode":null,"errorMessage":"teams_webhook: send failed: %w","messagePattern":"teams_webhook: send failed: %w","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/channels/teams_webhook/teams_webhook.go","lineNumber":182,"sourceCode":"\t}\n\n\t// Create the message with the card\n\tteamsMsg, err := adaptivecard.NewMessageFromCard(card)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"teams_webhook: failed to create message: %w\", err)\n\t}\n\n\t// Send to Teams\n\tif err := c.client.SendWithContext(ctx, target.WebhookURL.String(), teamsMsg); err != nil {\n\t\t// Log without raw error to avoid leaking webhook URL (embedded in net/http errors)\n\t\tlogger.ErrorCF(\"teams_webhook\", \"Failed to send message to Teams webhook\", map[string]any{\n\t\t\t\"target\": msg.ChatID,\n\t\t})\n\t\t// Classify error based on status code extracted from error message.\n\t\t// The go-teams-notify library includes status in errors like \"401 Unauthorized\".\n\t\t// Use ClassifySendError for proper retry behavior (4xx = permanent, 5xx = temporary).\n\t\tclassifiedErr := classifyTeamsError(err)\n\t\treturn nil, fmt.Errorf(\"teams_webhook: send failed: %w\", classifiedErr)\n\t}\n\n\tlogger.DebugCF(\"teams_webhook\", \"Message sent successfully\", map[string]any{\n\t\t\"target\": msg.ChatID,\n\t})\n\n\treturn nil, nil\n}\n\n// buildAdaptiveCard creates a formatted Adaptive Card from the outbound message.\n// It detects markdown tables and converts them to native Adaptive Card Table elements,\n// since TextBlocks only support a limited markdown subset (no tables).\nfunc (c *TeamsWebhookChannel) buildAdaptiveCard(\n\tmsg bus.OutboundMessage,\n\ttarget config.TeamsWebhookTarget,\n) (adaptivecard.Card, error) {\n\tcard := adaptivecard.NewCard()\n\tcard.Type = adaptivecard.TypeAdaptiveCard","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/pkg/channels/teams_webhook/teams_webhook.go#L164-L200","documentation":"Returned by TeamsWebhookChannel.Send when client.SendWithContext fails to deliver the message to the Teams webhook. The raw error is deliberately not logged or wrapped in detail because net/http errors embed the full webhook URL (a secret); the code classifies the failure by HTTP status code extracted from the error message.","triggerScenarios":"Thrown at pkg/channels/teams_webhook/teams_webhook.go:182 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Classify via the status code: 4xx (e.g. 400/401/404) means bad payload or expired webhook — fix or rotate the webhook; 5xx/429 are transient — retry with backoff","Check Azure/Teams service health for sustained 5xx","Verify the webhook URL has not been rotated or deleted in the Teams admin side"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","contentChangedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}