element-hq / element-x-ios

Next generation Matrix client for iOS built with SwiftUI on top of matrix-rust-sdk.
https://element.io/labs/element-x
GNU Affero General Public License v3.0
418 stars 98 forks source link

Failed retrieving file with error: Generic(msg: "File name too long (os error 63).. #3400

Open wrjlewis opened 2 weeks ago

wrjlewis commented 2 weeks ago

Steps to reproduce

  1. Where are you starting? What can you see? An image in a room with a long body

  2. What do you click? Click the image and expect the fullscreen popup but nothing appears

The error message in EX:

2024-10-11T11:57:52.534653Z ERROR elementx: Failed retrieving file with error: Generic(msg: "File name too long (os error 63) at path \"/private/var/mobile/Containers/Data/Application/E2163910-D333-4BE2-8C47-DA49E66164E4/tmp/.tmpKuU3Yw/Generated image based on: A stylized logo composed of an array of elements arranged in a matrix manner. The elements can be represented as different geometric shapes like squares, circles, or triangles. The colors used could be on a gradient scale, ranging from light to dark, to add depth. The entire composition evokes a feeling of organization and symmetry, combined with a touch of modern minimalistic design.\"") | MediaProvider.swift:125 | spans: root

Looks like EX is using the body as the filename, and at a specific length (255 chars) iOS and MacOS will error.

A fix could be to cut off the filename before the OS limit, or use a different identifier for the filename.

The body in the example:

"content" : {
    "body" : "Generated image based on: A stylized logo composed of an array of elements arranged in a matrix manner. The elements can be represented as different geometric shapes like squares, circles, or triangles. The colors used could be on a gradient scale, ranging from light to dark, to add depth. The entire composition evokes a feeling of organization and symmetry, combined with a touch of modern minimalistic design.",
    "info" : {
      "mimetype" : "image\/png",
      "size" : 415808
    },

Outcome

What did you expect?

Click the image and expect the fullscreen popup

What happened instead?

Nothing

Your phone model

iPhone 16

Operating system version

iOS 18.0.1

Application version

729

Homeserver

Synapse 117rc1

Will you send logs?

No

Velin92 commented 1 week ago

According to the specs we use the body as the filename only if the filename field is not specified. While I understand that files with a very long name might incur in this issue, and we will look into fixing it (we may just use a SHA of the body/filename when it's too long), at the same time I also feel that the filename field is made to allow the client to keep consistency of the filename between the process of upload and download. In the meantime my suggestion would be to send media always with a filename.