Skip to content

test(api): cover single-entity delete for non-markdown file entities - #1056

Merged
phernandez merged 2 commits into
mainfrom
test/1033-non-markdown-entity-delete
Jul 15, 2026
Merged

test(api): cover single-entity delete for non-markdown file entities#1056
phernandez merged 2 commits into
mainfrom
test/1033-non-markdown-entity-delete

Conversation

@phernandez

Copy link
Copy Markdown
Member

Summary

Adds a regression test locking in the #1002/#1054 fix for the issue-#1033 scenario: DELETE /v2/projects/{id}/knowledge/entities/{id} returned 500 for non-markdown (note_type="file") entities in v0.20.3 because the single-entity delete path did markdown-specific cleanup. The refactor on main fixed this by routing single-entity delete through the shared accepted-note delete path (delete_entity_by_idnote_content_mutation_service.delete_noterun_accepted_note_delete), which removes search/vector rows by entity id and tolerates entities with no note_content row — but nothing covered the non-markdown case.

Test

test_delete_entity_by_id_non_markdown_file_entity in tests/api/v2/test_knowledge_router.py:

  • indexes a real .csv through the local project indexer (run_local_project_index_for_project), producing a genuine file entity: note_type="file", no permalink, no note_content row — the exact shape that used to 500
  • asserts its search index row exists up front so the post-delete check is not vacuous
  • calls the v2 DELETE endpoint and asserts 202 + deleted: true
  • asserts the entity row and its search index rows are gone

The test passes on current main unmodified, proving the fix covers the #1033 scenario end-to-end.

Verification

  • uv run pytest tests/api/v2/test_knowledge_router.py -x -q — 64 passed
  • ruff check / ruff format clean; just typecheck diagnostics identical to main (pre-existing)

Refs #1033

🤖 Generated with Claude Code

@phernandez

Copy link
Copy Markdown
Member Author

Holding merge on one correctness gap: this test proves the endpoint no longer returns 500 and removes the database/search rows, but it does not assert that the source file is removed. On current main, the endpoint returns 202 with deleted: true while leaving the CSV on disk, so the file can be reindexed later.

The regression should assert not csv_path.exists(), and the implementation should delete the regular file through the accepted materialization path before we close #1033. The PR body should also avoid saying the issue is fully fixed until that behavior is covered.

phernandez and others added 2 commits July 14, 2026 23:36
DELETE /v2/projects/{id}/knowledge/entities/{id} used to return 500 for
note_type="file" entities (issue #1033) because the delete path did
markdown-specific cleanup. The #1002/#1054 refactor fixed this by routing
single-entity delete through the shared accepted-note delete path, but no
test covered the non-markdown case.

Add a regression test that indexes a real .csv file through the local
project indexer (note_type="file", no permalink, no note_content row),
deletes it via the v2 endpoint, and asserts the entity row and its search
index rows are gone.

Refs #1033

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: phernandez <paul@basicmachines.co>
Signed-off-by: phernandez <paul@basicmachines.co>
@phernandez

Copy link
Copy Markdown
Member Author

@codex review

recheck

@phernandez
phernandez force-pushed the test/1033-non-markdown-entity-delete branch from 1d57a9f to d7a0cca Compare July 15, 2026 04:36
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: d7a0cca370

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@phernandez
phernandez merged commit 9808ffa into main Jul 15, 2026
23 checks passed
@phernandez
phernandez deleted the test/1033-non-markdown-entity-delete branch July 15, 2026 04:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant