Creating a status with another status as an attachment causes odd behaviour
Environment
- Installation type (OTP or From Source): From Source
- Pleroma version (could be found in the "Version" tab of settings in Pleroma-FE): 2.5.52-0-g043a0099-develop+dev
- Elixir version (
elixir -v
for from source installations, N/A for OTP): Elixir 1.14.5 (compiled with Erlang/OTP 24) - Operating system: Arch Linux
- PostgreSQL version (
psql -V
): psql (PostgreSQL) 15.3
Bug description
Putting the id of a Note
object into media_ids
while creating a status through MastoAPI[1] causes the server to respond with a 500 internal server error[2]. The status gets created as expected (with the given note as an attachment)[3], but is missing when requesting a timeline including it via MastoAPI (with Pleroma throwing out a similar error as in [2] in the console while generating the response), and attempting to fetch an outbox containing it via the ActivityPub API causes the entire request to error out[4].
The errors seem to be due to all attachments generally being expected to have a "url" property (line 549 in status_view.ex, line 920 in transmogrifier.ex), something a Note
object does not have.
Footnotes
[1]: Status creation request
curl -X POST http://192.168.0.212/api/v1/statuses \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer KbJdU1trXXQ_fiDDt6b5F1HdP1RN3_kfcWAK32KgpXw' \
-d '{
"status": "Outer status",
"media_ids": ["5"]
}'
[2]: Status creation response
# MatchError at POST /api/v1/statuses
Exception:
** (MatchError) no match of right hand side value: nil
(pleroma 2.5.52-0-g043a00991-develop+dev) lib/pleroma/web/mastodon_api/views/status_view.ex:549: Pleroma.Web.MastodonAPI.StatusView.render/2
(elixir 1.14.5) lib/enum.ex:1658: Enum."-map/2-lists^map/1-0-"/2
(pleroma 2.5.52-0-g043a00991-develop+dev) lib/pleroma/web/mastodon_api/views/status_view.ex:265: Pleroma.Web.MastodonAPI.StatusView.render/2
(phoenix_view 2.0.2) lib/phoenix_view.ex:557: Phoenix.View.render_to_iodata/3
(phoenix 1.6.16) lib/phoenix/controller.ex:772: Phoenix.Controller.render_and_send/4
(pleroma 2.5.52-0-g043a00991-develop+dev) lib/pleroma/web/controller_helper.ex:96: Pleroma.Web.ControllerHelper.try_render/3
(pleroma 2.5.52-0-g043a00991-develop+dev) lib/pleroma/web/mastodon_api/controllers/status_controller.ex:5: Pleroma.Web.MastodonAPI.StatusController.action/2
(pleroma 2.5.52-0-g043a00991-develop+dev) lib/pleroma/web/mastodon_api/controllers/status_controller.ex:5: Pleroma.Web.MastodonAPI.StatusController.phoenix_controller_pipeline/2
(phoenix 1.6.16) lib/phoenix/router.ex:354: Phoenix.Router.__call__/2
(pleroma 2.5.52-0-g043a00991-develop+dev) lib/pleroma/web/endpoint.ex:5: Pleroma.Web.Endpoint.plug_builder_call/2
(pleroma 2.5.52-0-g043a00991-develop+dev) deps/plug/lib/plug/debugger.ex:132: Pleroma.Web.Endpoint."call (overridable 3)"/2
(pleroma 2.5.52-0-g043a00991-develop+dev) lib/pleroma/web/endpoint.ex:5: Pleroma.Web.Endpoint.call/2
(phoenix 1.6.16) lib/phoenix/endpoint/cowboy2_handler.ex:54: Phoenix.Endpoint.Cowboy2Handler.init/4
(cowboy 2.9.0) <pleroma dir>/deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2
(cowboy 2.9.0) <pleroma dir>/deps/cowboy/src/cowboy_stream_h.erl:306: :cowboy_stream_h.execute/3
(cowboy 2.9.0) <pleroma dir>/deps/cowboy/src/cowboy_stream_h.erl:295: :cowboy_stream_h.request_process/3
(stdlib 4.3.1.2) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
## Connection details
[ ... nothing interesting, removed for the sake of brevity ... ]
[3]: The status itself
{
"cc": [
"http://192.168.0.212/users/admin/followers"
],
"id": "http://192.168.0.212/objects/fcef8307-c06f-49b9-960e-644e5229b6da",
"to": [
"https://www.w3.org/ns/activitystreams#Public"
],
"tag": [],
"type": "Note",
"actor": "http://192.168.0.212/users/admin",
"emoji": {},
"source": {
"content": "Outer status",
"mediaType": "text/plain"
},
"content": "Outer status",
"context": "http://192.168.0.212/contexts/31e58e5d-0025-4fd0-a0ec-83cb412f63f6",
"summary": "",
"generator": null,
"published": "2023-07-05T22:18:42.057925Z",
"sensitive": null,
"attachment": [
{
"cc": [
"http://192.168.0.212/users/admin/followers"
],
"id": "http://192.168.0.212/objects/546ab72f-c71e-444a-8074-f07a8a1d92de",
"to": [
"https://www.w3.org/ns/activitystreams#Public"
],
"tag": [],
"type": "Note",
"actor": "http://192.168.0.212/users/admin",
"emoji": {},
"source": {
"content": "Inner status",
"mediaType": "text/plain"
},
"content": "Inner status",
"context": "http://192.168.0.212/contexts/822e1bef-16ca-43ae-84f5-fc35d4777c63",
"summary": "",
"generator": null,
"published": "2023-07-05T22:18:38.215127Z",
"sensitive": null,
"attachment": []
}
]
}
[4]: Outbox fetch response
# MatchError at GET /users/admin/outbox
Exception:
** (MatchError) no match of right hand side value: nil
(pleroma 2.5.52-0-g043a00991-develop+dev) lib/pleroma/web/activity_pub/transmogrifier.ex:920: anonymous fn/1 in Pleroma.Web.ActivityPub.Transmogrifier.prepare_attachments/1
(elixir 1.14.5) lib/enum.ex:1658: Enum."-map/2-lists^map/1-0-"/2
(pleroma 2.5.52-0-g043a00991-develop+dev) lib/pleroma/web/activity_pub/transmogrifier.ex:919: Pleroma.Web.ActivityPub.Transmogrifier.prepare_attachments/1
(pleroma 2.5.52-0-g043a00991-develop+dev) lib/pleroma/web/activity_pub/transmogrifier.ex:682: Pleroma.Web.ActivityPub.Transmogrifier.prepare_object/1
(pleroma 2.5.52-0-g043a00991-develop+dev) lib/pleroma/web/activity_pub/transmogrifier.ex:720: Pleroma.Web.ActivityPub.Transmogrifier.prepare_outgoing/1
(pleroma 2.5.52-0-g043a00991-develop+dev) lib/pleroma/web/activity_pub/views/user_view.ex:242: anonymous fn/1 in Pleroma.Web.ActivityPub.UserView.render/2
(elixir 1.14.5) lib/enum.ex:1658: Enum."-map/2-lists^map/1-0-"/2
(pleroma 2.5.52-0-g043a00991-develop+dev) lib/pleroma/web/activity_pub/views/user_view.ex:241: Pleroma.Web.ActivityPub.UserView.render/2
(phoenix_view 2.0.2) lib/phoenix_view.ex:557: Phoenix.View.render_to_iodata/3
(phoenix 1.6.16) lib/phoenix/controller.ex:772: Phoenix.Controller.render_and_send/4
(pleroma 2.5.52-0-g043a00991-develop+dev) lib/pleroma/web/activity_pub/activity_pub_controller.ex:5: Pleroma.Web.ActivityPub.ActivityPubController.action/2
(pleroma 2.5.52-0-g043a00991-develop+dev) lib/pleroma/web/activity_pub/activity_pub_controller.ex:5: Pleroma.Web.ActivityPub.ActivityPubController.phoenix_controller_pipeline/2
(phoenix 1.6.16) lib/phoenix/router.ex:354: Phoenix.Router.__call__/2
(pleroma 2.5.52-0-g043a00991-develop+dev) lib/pleroma/web/endpoint.ex:5: Pleroma.Web.Endpoint.plug_builder_call/2
(pleroma 2.5.52-0-g043a00991-develop+dev) deps/plug/lib/plug/debugger.ex:132: Pleroma.Web.Endpoint."call (overridable 3)"/2
(pleroma 2.5.52-0-g043a00991-develop+dev) lib/pleroma/web/endpoint.ex:5: Pleroma.Web.Endpoint.call/2
(phoenix 1.6.16) lib/phoenix/endpoint/cowboy2_handler.ex:54: Phoenix.Endpoint.Cowboy2Handler.init/4
(cowboy 2.9.0) <pleroma dir>/deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2
(cowboy 2.9.0) <pleroma dir>/deps/cowboy/src/cowboy_stream_h.erl:306: :cowboy_stream_h.execute/3
(cowboy 2.9.0) <pleroma dir>/deps/cowboy/src/cowboy_stream_h.erl:295: :cowboy_stream_h.request_process/3
## Connection details
[ ... nothing interesting, removed for the sake of brevity ... ]