feat: add opt-in strict chunk_index validation#14
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds an opt-in “strict mode” validation path to REST::insert_embedding_row() to prevent silently defaulting invalid chunk_index values to 0, helping catch caller regressions early while preserving current default behavior.
Changes:
- Introduces
wpvdb_strict_chunk_indexfilter (defaultfalse) to gate strict validation. - When strict mode is enabled, rejects
chunk_indexvalues that arenull, non-numeric, or negative with aWP_Error(chunk_index_invalid, status400). - Keeps existing warn-and-default-to-0 behavior unchanged when strict mode is disabled.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-Authored-By: Codex <codex@openai.com>
Co-Authored-By: Codex <codex@openai.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-Authored-By: Codex <codex@openai.com>
Co-Authored-By: Codex <codex@openai.com>
|
Independently re-validated the whole PR before merge: Tests: Feature ( Copilot review points, all verified in code:
Pre-existing note (not introduced here): Mergeable and CLEAN. |
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Folded a Removed the |
Summary
Adds an opt-in strict mode to
REST::insert_embedding_row(). When thewpvdb_strict_chunk_indexfilter returnstrue, a null, non-numeric, or negativechunk_indexis rejected with aWP_Error(chunk_index_invalid, status 400) instead of silently defaulting to0.Background
062a942gavechunk_indexa null default plus aWP_DEBUGwarning, then falls back to0. That silent fallback is exactly the class of regression that produced the original all-chunk_index=0corpus bug. Strict mode lets a site (or CI) opt into failing loudly so a caller passing a badchunk_indexis caught immediately.Default behavior is unchanged: the filter defaults to
false, so the legacy warn-then-default-to-0 path runs byte-for-byte as before. The new branch mirrors the existingembedding_invalidvalidation right below it (sameLogger::error+WP_Errorshape withstatus => 400).Testing
php -lclean.phpcs --standard=phpcs.xml.distintroduces zero new violations (15 errors / 18 warnings before and after, all pre-existing baseline in this file). Default path untouched; only the new filter-gated branch is added.🤖 Generated with Claude Code