An empty media_ids takes an edited post's media away

A JSON body's empty array flattened to nothing, so `media_ids: []` on an edit read as "media not sent" and the
post kept every attachment, where Mastodon removes them. An empty array is now a parameter with no values: the edit
leaves the post without media, and they go to the trash. MediaLifecycleTests checks it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LsXgEaXee4GCU1hwYgPJXw
This commit is contained in:
thepraandClaude Opus 5.5 committed 2026-10-07 11:07:17 +02:00
1 parent dc63fa57b8
commit 830385ea2b
2 files changed
+11 -1

No files matched your search

@@ -89,6 +89,9 @@ namespace PrivaPub.Api.Mastodon.Infrastructure
Flatten(values, prefix == default ? property.Name : $"{prefix}[{property.Name}]", property.Value);
break;
case JsonValueKind.Array:
// an empty array is still said: media_ids: [] on an edit takes every attachment away
if (prefix != default && element.GetArrayLength() == 0)
values.TryAdd(prefix, new List<string>());
foreach (var item in element.EnumerateArray())
{
if (item.ValueKind is JsonValueKind.Object or JsonValueKind.Array)