rewrite_media_domain does not rewrite user image URLs #1064

Closed
opened 2026-02-19 08:59:41 +00:00 by Yonle · 6 comments
Contributor

Your setup

From source

Extra details

No response

Version

Stable v3.17.0

PostgreSQL version

18

What were you trying to do?

I am trying to rewrite the media domain on every post from my local instance.

What did you expect to happen?

Changes the host of the media

What actually happened?

Error

Logs

```
Rewriting media domain from https://eu2.contabostorage.com/3a3d6ee44cde4ea7a62833da64ec81d1:fedi to https://media.fedinet.waltuh.cyou/media
Dry run: false

08:57:42.699 [debug] QUERY OK source="objects" db=405.9ms queue=4.6ms idle=344.8ms
SELECT o0."id", o0."data", o0."inserted_at", o0."updated_at" FROM "objects" AS o0 WHERE (o0."data"->'url'->0->>'href' LIKE $1
      OR
      o0."data"->'attachment'->0->'url'->0->>'href' LIKE $2) AND (o0."id" > $3) ORDER BY o0."id" LIMIT $4 ["https://eu2.contabostorage.com/3a3d6ee44cde4ea7a62833da64ec81d1:fedi%", "https://eu2.contabostorage.com/3a3d6ee44cde4ea7a62833da64ec81d1:fedi%", 0, 100]
%{"id" => "https://fedinet.waltuh.cyou/objects/5d1a1866-0d38-4fc7-a82b-5079ed708326", "mediaType" => "image/jpeg", "name" => "", "type" => "Image", "url" => [%{"href" => "https://eu2.contabostorage.com/3a3d6ee44cde4ea7a62833da64ec81d1:fedi/fedi/37a721142a8db7b08839125d54e81a640ccd93f8902fa970bc16ab20464b0ef1.jpg", "mediaType" => "image/jpeg", "type" => "Link"}]}
** (RuntimeError) Unhandled object format!
    (pleroma 3.17.0) lib/mix/tasks/pleroma/uploads.ex:200: Mix.Tasks.Pleroma.Uploads.rewrite_url_object/4
    (pleroma 3.17.0) lib/mix/tasks/pleroma/uploads.ex:132: anonymous fn/4 in Mix.Tasks.Pleroma.Uploads.run/1
    (elixir 1.19.3) lib/enum.ex:961: Enum."-each/2-lists^foreach/1-0-"/2
    (elixir 1.19.3) lib/stream.ex:499: anonymous fn/4 in Stream.each/2
    (elixir 1.19.3) lib/stream.ex:1603: Stream.do_element_resource/6
    (elixir 1.19.3) lib/stream.ex:1773: Enumerable.Stream.do_each/4
    (elixir 1.19.3) lib/stream.ex:707: Stream.run/1
    (mix 1.19.3) lib/mix/task.ex:499: anonymous fn/3 in Mix.Task.run_task/5
```

Severity

I cannot use it as easily as I'd like

Have you searched for this issue?

  • I have double-checked and have not found this issue mentioned anywhere.
### Your setup From source ### Extra details _No response_ ### Version Stable v3.17.0 ### PostgreSQL version 18 ### What were you trying to do? I am trying to rewrite the media domain on every post from my local instance. ### What did you expect to happen? Changes the host of the media ### What actually happened? Error ### Logs ````shell ``` Rewriting media domain from https://eu2.contabostorage.com/3a3d6ee44cde4ea7a62833da64ec81d1:fedi to https://media.fedinet.waltuh.cyou/media Dry run: false 08:57:42.699 [debug] QUERY OK source="objects" db=405.9ms queue=4.6ms idle=344.8ms SELECT o0."id", o0."data", o0."inserted_at", o0."updated_at" FROM "objects" AS o0 WHERE (o0."data"->'url'->0->>'href' LIKE $1 OR o0."data"->'attachment'->0->'url'->0->>'href' LIKE $2) AND (o0."id" > $3) ORDER BY o0."id" LIMIT $4 ["https://eu2.contabostorage.com/3a3d6ee44cde4ea7a62833da64ec81d1:fedi%", "https://eu2.contabostorage.com/3a3d6ee44cde4ea7a62833da64ec81d1:fedi%", 0, 100] %{"id" => "https://fedinet.waltuh.cyou/objects/5d1a1866-0d38-4fc7-a82b-5079ed708326", "mediaType" => "image/jpeg", "name" => "", "type" => "Image", "url" => [%{"href" => "https://eu2.contabostorage.com/3a3d6ee44cde4ea7a62833da64ec81d1:fedi/fedi/37a721142a8db7b08839125d54e81a640ccd93f8902fa970bc16ab20464b0ef1.jpg", "mediaType" => "image/jpeg", "type" => "Link"}]} ** (RuntimeError) Unhandled object format! (pleroma 3.17.0) lib/mix/tasks/pleroma/uploads.ex:200: Mix.Tasks.Pleroma.Uploads.rewrite_url_object/4 (pleroma 3.17.0) lib/mix/tasks/pleroma/uploads.ex:132: anonymous fn/4 in Mix.Tasks.Pleroma.Uploads.run/1 (elixir 1.19.3) lib/enum.ex:961: Enum."-each/2-lists^foreach/1-0-"/2 (elixir 1.19.3) lib/stream.ex:499: anonymous fn/4 in Stream.each/2 (elixir 1.19.3) lib/stream.ex:1603: Stream.do_element_resource/6 (elixir 1.19.3) lib/stream.ex:1773: Enumerable.Stream.do_each/4 (elixir 1.19.3) lib/stream.ex:707: Stream.run/1 (mix 1.19.3) lib/mix/task.ex:499: anonymous fn/3 in Mix.Task.run_task/5 ``` ```` ### Severity I cannot use it as easily as I'd like ### Have you searched for this issue? - [x] I have double-checked and have not found this issue mentioned anywhere.
Owner

looks like the task currently can't handle local Image objects (used for user image (profile, banner, background) uploads; Document is used for all local attachments) to me. However, in that case it should have already failed everywhere when testing on ihba. Am I missing something? cc @floatingghost

looks like the task currently can't handle local `Image` objects *(used for user image (profile, banner, background) uploads; `Document` is used for all local attachments)* to me. However, in that case it should have already failed everywhere when testing on ihba. Am I missing something? cc @floatingghost

hmm I don't think you're missing anything, I don't recall it failing at any point on ihba

but it is possible that I manually updated something prior to running the rewrite task

hmm I don't think you're missing anything, I don't recall it failing at any point on ihba but it is possible that I manually updated something prior to running the rewrite task
Owner

should be just as simple as changing the "Document" match to also accept "Image" then. Made and merged a PR for this.

@Yonle please upgrade to develop and try again. Should you experience further problems with the task, reopen this issue with the new error details and/or further information.

should be just as simple as changing the `"Document"` match to also accept `"Image"` then. Made and merged a PR for this. @Yonle please upgrade to develop and try again. Should you experience further problems with the task, reopen this issue with the new error details and/or further information.
Author
Contributor

That commit fixed it. Thanks!

That commit fixed it. Thanks!
Author
Contributor

Apparently, it did updated posts urls, but user profile (profile pic, banner, wallpaper) is not getting updated.

however i think it's safe as of now.

Apparently, it did updated posts urls, but user profile (profile pic, banner, wallpaper) is not getting updated. however i think it's safe as of now.
Oneric changed title from [bug] rewrite_media_domain failed to run to rewrite_media_domain does not rewrite user image URLs 2026-02-20 13:44:28 +00:00
Owner

Ahh right, i was only thinking of how to correctly update the objects table.

Due to the subpar media db scheme (one day, hopefully there’ll be time for #765) we have Image entries in objects tracking that a user image was uploaded, but users entries do not reference it instead duplicating URLs. Meaning, everything the task currently does is correct, but it also needs an additional pass over local users to updated their (duped) avatar, banner and background URLs.

Ahh right, i was only thinking of how to correctly update the `objects` table. Due to the subpar media db scheme *(one day, hopefully there’ll be time for #765)* we have `Image` entries in `objects` tracking that a user image was uploaded, but `users` entries do not reference it instead duplicating URLs. Meaning, everything the task currently does is correct, but it also needs an additional pass over local `users` to updated their (duped) avatar, banner and background URLs.
Oneric reopened this issue 2026-02-20 13:45:23 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
AkkomaGang/akkoma#1064
No description provided.