Skip to content

[Bug]: Modify thread message throws 'attachments' key exception #470

@datashaman

Description

@datashaman

Description

When modifying a thread message's metadata after creation, the call to do so fails with:

  ErrorException

  Undefined array key "attachments"

  at vendor/openai-php/client/src/Responses/Threads/Messages/ThreadMessageResponse.php:64
     60▕         );
     61▕
     62▕         $attachments = array_map(
     63▕             fn (array $attachment): ThreadMessageResponseAttachment => ThreadMessageResponseAttachment::from($attachment),
  ➜  64▕             $attributes['attachments']
     65▕         );
     66▕
     67▕         return new self(
     68▕             $attributes['id'],

Steps To Reproduce

$thread = $client->threads()->create([]);

$message = $client->threads()->messages()->create($thread->id, [
    'role' => 'user',
    'content' => 'Explain deep learning to a 5 year old.',
]);

$response = $client->threads()->messages()->modify(
    threadId: $thread->id,
    messageId: $message->id,
    parameters: [
        'metadata' => [
            'key' => 'value',
        ],
    ]
);

OpenAI PHP Client Version

dev-main

PHP Version

8.3.9

Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions