sipeed/picoclaw · error
teams_webhook: failed to create message
Error message
teams_webhook: failed to create message: %w
What it means
Returned by TeamsWebhookChannel.Send when adaptivecard.NewMessageFromCard rejects the card that was just built. This is a library-level serialization failure of the Adaptive Card payload, wrapped with %w; the card structure was produced but does not conform to what the message encoder accepts.
Solutions
- Inspect the wrapped error for which card element was rejected
- Simplify the message formatting (drop tables or complex nesting) and resend
- Report upstream if the same card shape always fails in NewMessageFromCard
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at pkg/channels/teams_webhook/teams_webhook.go:169 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of sipeed/picoclaw@49183d7e8d (2026-08-15).
Data as JSON: /api/errors/25dd05f5f65f6fe6.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/channels/teams_webhook/teams_webhook.go:169
if !ok {
// Log warning and fall back to default target
logger.WarnCF("teams_webhook", "Unknown target, falling back to default", map[string]any{
"requested": msg.ChatID,
"using": "default",
})
target = c.config.Webhooks["default"]
}
// Build an Adaptive Card for rich formatting
card, err := c.buildAdaptiveCard(msg, target)
if err != nil {
return nil, fmt.Errorf("teams_webhook: failed to build card: %w", err)
}
// Create the message with the card
teamsMsg, err := adaptivecard.NewMessageFromCard(card)
if err != nil {
return nil, fmt.Errorf("teams_webhook: failed to create message: %w", err)
}
// Send to Teams
if err := c.client.SendWithContext(ctx, target.WebhookURL.String(), teamsMsg); err != nil {
// Log without raw error to avoid leaking webhook URL (embedded in net/http errors)
logger.ErrorCF("teams_webhook", "Failed to send message to Teams webhook", map[string]any{
"target": msg.ChatID,
})
// Classify error based on status code extracted from error message.
// The go-teams-notify library includes status in errors like "401 Unauthorized".
// Use ClassifySendError for proper retry behavior (4xx = permanent, 5xx = temporary).
classifiedErr := classifyTeamsError(err)
return nil, fmt.Errorf("teams_webhook: send failed: %w", classifiedErr)
}
logger.DebugCF("teams_webhook", "Message sent successfully", map[string]any{
"target": msg.ChatID,
})View on GitHub (pinned to 49183d7e8d)