bluesky-social / atproto

Social networking technology created by Bluesky
Other
7.21k stars 510 forks source link

ATProto/api: createRecord returns "Bad Request" on post with media embeds and omitted text property #2938

Open codemasher opened 3 weeks ago

codemasher commented 3 weeks ago

Describe the bug

When attempting to create a post with one or more images (or other media, I assume) and an omitted text property, the endpoint returns a Bad Request.

To Reproduce

Steps to reproduce the behavior:

  1. Attempt to create a new post
  2. Upload and attach media files to embed
  3. Omit the text property
$body = [
    'collection' => 'app.bsky.feed.post',
    'repo'       => '<repo-did>',
    'record'     => [
        // the text property is empty and can be omitted
        'text'      => '',
        'createdAt' => date('c'),
        '$type'     => 'app.bsky.feed.post',
        'embed'     => [
            '$type'  => 'app.bsky.embed.images',
            'images' => [/* array of one or more images*/],
        ],
    ],
];

Expected behavior

The post should be created and a 200/OK should be returned instead. A post without text body and only media embeds is perfectly valid.

Details

Additional context

I see that in the Lexicon, the text property is listed as required

https://github.com/bluesky-social/atproto/blob/8a4d06c367691fec359be21ed46418111b39231f/lexicons/app/bsky/feed/post.json#L11

It should be conditional instead, depending on whether the body contains media/other embeds.