Reject non-finite values in embedding vectors#263
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## trunk #263 +/- ##
=========================================
Coverage 86.49% 86.50%
- Complexity 1327 1330 +3
=========================================
Files 68 68
Lines 4295 4298 +3
=========================================
+ Hits 3715 3718 +3
Misses 580 580
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
One downstream coordination note: WordPress/wordpress-develop#12530 currently imports PHP AI Client 1.4.0 for the WordPress 7.1 embedding API, so its vendored If this fix looks right, would a 1.4.1 patch release followed by updating #12530 to that tag be the cleanest path? I’m not suggesting this should block the Core wrapper review—just flagging the dependency while the import is still open. |
Summary
NAN,INF, and-INFat theEmbeddingconstructor boundary.Fixes #262.
Why
Non-finite values satisfy PHP's
is_float()check but cannot be represented in JSON. Rejecting them when constructing anEmbeddingprevents an invalid result object from failing later during serialization, logging, caching, persistence, or custom provider handling.Testing
A test-only commit first demonstrated the gap: all three new cases failed because no
InvalidArgumentExceptionwas thrown.After the implementation commit:
AI assistance