Skip to content

**Misleading "Codec type is not registered" error for RemoteAttachment** #467

@mchenani

Description

@mchenani

Summary

When sending a message, users receive a confusing error message stating "Codec type is not registered" even when both and are properly registered. The actual issue is that the object is missing required properties ( and ). RemoteAttachment``RemoteAttachmentCodec``AttachmentCodec``RemoteAttachment``contentLength``filename

Current Behavior

  • Error message: "Codec type is not registered"
  • Users assume the codec registration is the problem
  • The actual cause (missing required properties) is not communicated

Expected Behavior

  • Clear, specific error message indicating which required properties are missing
  • Error message should help developers understand the actual problem

Root Cause

The issue occurs when a is created without setting the required and properties. The codec fails during encoding/decoding, but the error handling incorrectly reports this as a codec registration issue rather than a validation/encoding failure. RemoteAttachment``contentLength``filename

Workaround

Ensure all required properties are set before sending:

val remoteAttachment = RemoteAttachment.from(
    encryptedEncodedContent = contents[0].second,
    url = URL(contents[0].first.assetUrl),
)
remoteAttachment.contentLength = attachment.data.size()
remoteAttachment.filename = attachment.filename

Proposed Solution

  1. Improve error handling: Catch codec encoding failures and provide more specific error messages
  2. Add validation: Validate properties before attempting to encode RemoteAttachment
  3. Better error messages: Replace generic "Codec type is not registered" with specific validation errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions