chenhg5/cc-connect · error
%s: build video message: %w
Error message
%s: build video message: %w
What it means
Failed to serialize the larkim.MessageMedia struct (containing the uploaded file_key) into the JSON message content string via mediaMsg.String(). This is a local JSON-marshalling failure, not an API failure.
Source
Thrown at platform/feishu/feishu.go:5587
if !uploadResp.Success() {
return fmt.Errorf("%s: upload video code=%d msg=%s", p.tag(), uploadResp.Code, uploadResp.Msg)
}
return nil
})
}); err != nil {
return err
}
if uploadResp.Data == nil || uploadResp.Data.FileKey == nil {
return fmt.Errorf("%s: upload video: no file_key returned", p.tag())
}
fileKey := *uploadResp.Data.FileKey
slog.Debug(p.tag()+": video uploaded", "file_key", fileKey, "format", format, "size", len(video))
mediaMsg := larkim.MessageMedia{FileKey: fileKey}
mediaContent, err := mediaMsg.String()
if err != nil {
return fmt.Errorf("%s: build video message: %w", p.tag(), err)
}
return p.sendMediaMessage(ctx, rc, larkim.MsgTypeMedia, mediaContent)
}
type postElement struct {
Tag string `json:"tag"`
Text string `json:"text,omitempty"`
Language string `json:"language,omitempty"`
ImageKey string `json:"image_key,omitempty"`
Href string `json:"href,omitempty"`
UserId string `json:"user_id,omitempty"`
UserName string `json:"user_name,omitempty"`
}
type postLang struct {
Title string `json:"title"`
Content [][]postElement `json:"content"`View on GitHub (pinned to 4000b2338a)
Solutions
- Upgrade/reinstall the Feishu SDK — a stock MessageMedia with a valid fileKey always marshals
- Verify fileKey contains only the plain key string (no control characters injected)
- Check vendor directory integrity (go mod verify)
- If it persists, replace mediaMsg.String() with explicit json.Marshal of a map for debugging
Defensive patterns
Strategy: try-catch
Try / catch
content, err := mediaMsg.String()
if err != nil {
slog.Error("media marshal failed", "err", err)
return err
} Prevention
- Run go mod verify to catch corrupted SDK installs
- Never inject control characters into fileKey
When it happens
Trigger: mediaMsg.String() returns an error, which for larkim.MessageContent implementations is practically only a json.Marshal failure — essentially never with a plain FileKey string field.
Common situations: Extremely rare in practice; could indicate a corrupted SDK install or a custom MessageMedia build with unmarshalable fields.
Understand the failure class
Background: json.Marshal / "failed to marshal" errors in Go: why "unsupported type" happens and how to fix it — this error's family across 22 libraries.
Related errors
- marshal Agy permission hook: %w
- marshal Agy hooks overlay: %w
- marshal stdin: %w
- codex app-server encode: %w
- decode response: %w
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/450cac6c6b2bb9cc.
Report an issue: GitHub.