Skip to content

Prevent accessing array index on null - #351

Merged
julien-nc merged 1 commit into
mainfrom
fix/noid/audio-attachment-check
Sep 5, 2025
Merged

Prevent accessing array index on null#351
julien-nc merged 1 commit into
mainfrom
fix/noid/audio-attachment-check

Conversation

@julien-nc

@julien-nc julien-nc commented Sep 5, 2025

Copy link
Copy Markdown
Member

When checking if the last attachment is an audio one right before scheduling the task to generate a new message.

This goes well with some Php configs that are not strict. It can also crash.

Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
@julien-nc julien-nc added bug Something isn't working 3. to review labels Sep 5, 2025
@@ -500,8 +500,9 @@ public function generateForSession(int $sessionId, int $agencyConfirm = 0): JSON

$lastAttachments = $lastUserMessage->jsonSerialize()['attachments'];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we're here, are we sure that ['attachments'] is set?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@julien-nc
julien-nc merged commit 4164b51 into main Sep 5, 2025
16 checks passed
@julien-nc
julien-nc deleted the fix/noid/audio-attachment-check branch September 5, 2025 14:11
@julien-nc julien-nc mentioned this pull request Sep 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants