fix(vector): guard unbound doc_task + address review nits (#891)

Round-1 review on PR #891:
- Guard processor_task's broad except handler against an unbound doc_task
  (mirrors multi_user_processor_task): initialise doc_task=None before the loop
  and branch the error log. Fixes a latent NameError if receive() raises a
  non-TimeoutError/EndOfStream before the first document binds. Regression test
  added.
- Drop the unnecessary `from __future__ import annotations` in vector/_errors.py
  and express format_exception_group's non-group fast path as an explicit
  isinstance check.
- Add a copy_resource Destination-header encoding test (analogue to MOVE);
  strengthen the ExceptionGroup test to assert the full leaf repr survives.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Chris Coutinho
2026-06-11 05:31:56 +02:00
co-authored by Claude Opus 4.8
parent 0388735593
commit a188e9fced
5 changed files with 96 additions and 12 deletions
+20
View File
@@ -588,3 +588,23 @@ async def test_move_resource_encodes_destination_header(mocker):
destination = call.kwargs["headers"]["Destination"]
assert "%23" in destination
assert "#" not in destination
@pytest.mark.unit
async def test_copy_resource_encodes_destination_header(mocker):
"""The COPY Destination header must be percent-encoded too (card 309)."""
mock_http_client = AsyncMock()
client = WebDAVClient(mock_http_client, "testuser")
mock_response = AsyncMock()
mock_response.status_code = 201
mock_response.raise_for_status = mocker.Mock()
mock_http_client.request = AsyncMock(return_value=mock_response)
await client.copy_resource("a/old.pdf", "b/new #1.pdf")
call = mock_http_client.request.call_args
assert call[0][1] == "/remote.php/dav/files/testuser/a/old.pdf"
destination = call.kwargs["headers"]["Destination"]
assert "%23" in destination
assert "#" not in destination