A collaborator explicitly asked that test files not be included on the PR. This follow-up keeps the file reindex safety fix intact while dropping the newly added repository test file, and relies on focused local verification outside the tracked diff instead.
Constraint: Keep the data-loss fix intact while removing the only PR artifact a reviewer objected to
Rejected: Leave the new test file in place and wait | direct reviewer feedback is already available and easy to satisfy
Confidence: medium
Scope-risk: narrow
Reversibility: clean
Directive: For this PR, preserve the reindex ordering fix but avoid re-adding a dedicated repository test file unless a maintainer explicitly asks for one
Tested: python3 -m py_compile backend/open_webui/routers/files.py backend/open_webui/utils/knowledge_collections.py; focused local harness for reindex_file_in_collection success/failure ordering
Not-tested: Repository pytest suite after dropping the tracked test file
A file content update should not leave knowledge collections emptier than before. The previous flow deleted old vectors first and then attempted the rebuild, so any downstream processing failure could leave the KB without embeddings even though the route returned success.\n\nThis change rebuilds the file's knowledge entries first and only deletes the stale vector ids after the new insert succeeds. The fix is kept narrow to the file-update propagation path and adds a focused regression test for the helper that preserves old ids when reindexing raises.\n\nConstraint: Keep the fix scoped to one retrieval correctness bug without refactoring broader embedding flows\nRejected: Fail the route after deleting old vectors | still leaves the KB empty and does not preserve data\nRejected: Broad temporary-collection refactor | larger than needed for a first bugfix PR\nConfidence: high\nScope-risk: narrow\nReversibility: clean\nDirective: Preserve old vector ids until rebuild success remains observable in tests; do not revert to delete-first ordering\nTested: py_compile on modified modules; PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 PYTHONPATH=backend pytest -q backend/open_webui/test/util/test_knowledge_collections.py; local source-faithful harness reproducing old failure mode\nNot-tested: Full application boot with live vector database backends