Skip to content

Fix invalid Message role and null response in HandlesRateLimiting#150

Merged
taylorotwell merged 5 commits intolaravel:0.xfrom
monayemislam:0.x
Feb 19, 2026
Merged

Fix invalid Message role and null response in HandlesRateLimiting#150
taylorotwell merged 5 commits intolaravel:0.xfrom
monayemislam:0.x

Conversation

@monayemislam
Copy link
Contributor

Changes

  • Message.php: When a string is passed as $role that doesn't match any MessageRole enum case, MessageRole::tryFrom($role) returns null and was assigned to the non-nullable $role property, causing a TypeError. Now throws InvalidArgumentException('Invalid message role.') with a clear message.

  • HandlesRateLimiting.php: RequestException can have a null response when the request never completed (e.g. connection timeout, DNS failure). Accessing $e->response->status() without a check could cause a null dereference. Now checks $e->response !== null before reading ->status().

@monayemislam
Copy link
Contributor Author

@taylorotwell can you please check this.

@taylorotwell taylorotwell merged commit dd34a10 into laravel:0.x Feb 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants