[wp-trac] [WordPress Trac] #65094: AI: Prompt construction fails with fatal error when wp_ai_client_default_request_timeout filter returns negative number
WordPress Trac
noreply at wordpress.org
Sun Apr 26 23:59:48 UTC 2026
#65094: AI: Prompt construction fails with fatal error when
wp_ai_client_default_request_timeout filter returns negative number
-------------------------------------------------+-------------------------
Reporter: westonruter | Owner:
| westonruter
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 7.0
Component: AI | Version:
Severity: normal | Resolution: fixed
Keywords: has-patch has-unit-tests commit | Focuses:
dev-reviewed |
-------------------------------------------------+-------------------------
Changes (by peterwilsoncc):
* status: reopened => closed
* resolution: => fixed
Comment:
In [changeset:"62266" 62266]:
{{{
#!CommitTicketReference repository="" revision="62266"
AI: Validate filtered default request timeout in
`WP_AI_Client_Prompt_Builder`.
This checks that the return value of the
`wp_ai_client_default_request_timeout` filter is a non-negative number
before passing it to `RequestOptions`. If the filtered value is invalid,
it is discarded in favor of the original default of `30.0` and a
`_doing_it_wrong()` notice is issued. Without this check, a fatal error
would ensue from the exception thrown in
`\WordPress\AiClient\Providers\Http\DTO\RequestOptions::validateTimeout()`.
The following static analysis issues are addressed:
* Use `float` instead of `int` for the
`wp_ai_client_default_request_timeout` filter parameter.
* Add missing PHP imports for `Message` and `MessagePart` in the PHPDoc
for `wp_ai_client_prompt()`.
* Add PHP return type hints for `wp_ai_client_prompt()` and
`WP_AI_Client_Cache::getMultiple()`.
* Use native property type hints in `WP_AI_Client_HTTP_Client`.
Developed in https://github.com/WordPress/wordpress-develop/pull/11596
Reviewed by peterwilsoncc.
Merges r62255 to the 7.0 branch.
Props westonruter, justlevine, flixos90, khushdoms, darshitrajyaguru97,
adrmf25, jarodortegaaraya, tusharaddweb, gaurangsondagar.
Fixes #65094.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/65094#comment:32>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list