Opt-in config for surfacing import failures - #33
Merged
ryanmitchell merged 2 commits intoJul 17, 2026
Conversation
ryanmitchell
approved these changes
Jul 17, 2026
Contributor
|
Thanks! |
Contributor
|
Sorry, I've just realised you targeted v2, can you re-open and target main, we're only providing security fixes on v2 now |
Author
|
I can bring it to v6 as well, but we urgently need it on v5. We currently can not update to v6 right away unfortunately. |
Contributor
|
You'd be better using your own fork for your v5 requirement. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Typesense's bulk import endpoint returns HTTP 200 even when individual documents are rejected (schema type mismatch, missing required field, etc.). The per-document outcomes are returned in the response body, and typesense-php returns them from
Documents::import()— it only throws on transport/HTTP errors.The driver currently discards that return value, so rejected documents silently vanish from the search index: no log entry, no exception. We lost documents from the index due to a schema type mismatch and only found out much later when content was missing from search results.
Solution
Index::insertDocuments()now inspects the import results and collects failures.throw_on_import_failureconfig key (defaultfalse). When enabled, anImportFailedExceptionis thrown instead, carrying the raw failures array ($e->failures()) and index name ($e->index()) so callers can inspect them.return_id, so Typesense includes the document id in each result line (newer Typesense versions no longer echo the full document on failure by default).Before
Nothing. Documents are dropped without a trace.
After
Alternative considered
Dispatching an event (e.g.
DocumentsImportFailed) instead of logging, and letting users decide how to react. That would be more flexible but requires users to opt in to get any signal at all — the main goal here is that failures are visible by default. Happy to rework it that way if you'd prefer.