chenhg5/cc-connect · error

matrix: upload image

Error message

matrix: upload image: %w

What it means

Wrapped error from mautrix client.UploadMedia when uploading image bytes to the Matrix content repository; the homeserver's media upload endpoint rejected or failed the request (size limit, auth, network).

Solutions

  1. Check media repo size limits and homeserver availability
  2. Retry on transient errors
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at platform/matrix/matrix.go:476 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/ba85a6b06ff0925c. Report an issue: GitHub.

Appendix: source

Thrown at platform/matrix/matrix.go:476

		return fmt.Errorf("matrix: not connected")
	}

	mime := img.MimeType
	if mime == "" {
		mime = "image/png"
	}
	name := img.FileName
	if name == "" {
		name = "image"
	}

	uri, err := client.UploadMedia(ctx, mautrix.ReqUploadMedia{
		ContentBytes: img.Data,
		ContentType:  mime,
		FileName:     name,
	})
	if err != nil {
		return fmt.Errorf("matrix: upload image: %w", err)
	}

	content := &event.MessageEventContent{
		MsgType: event.MsgImage,
		Body:    name,
		Info: &event.FileInfo{
			MimeType: mime,
			Size:     len(img.Data),
		},
	}
	if !uri.ContentURI.IsEmpty() {
		content.URL = uri.ContentURI.CUString()
	} else {
		content.File = &event.EncryptedFileInfo{
			URL: uri.ContentURI.CUString(),
		}
	}

View on GitHub (pinned to 4000b2338a)