Skip to content

Conversation

@leoguillaume
Copy link
Member

No description provided.

@leoguillaume leoguillaume self-assigned this Jan 16, 2026
@leoguillaume leoguillaume linked an issue Jan 16, 2026 that may be closed by this pull request
17 tasks
@coderabbitai
Copy link

coderabbitai bot commented Jan 16, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 592-document-add-postpatchdelete-v1chunks

Tip

🧪 Unit Test Generation v2 is now available!

We have significantly improved our unit test generation capabilities.

To enable: Add this to your .coderabbit.yaml configuration:

reviews:
  finishing_touches:
    unit_tests:
      enabled: true

Try it out by using the @coderabbitai generate unit tests command on your code files or under ✨ Finishing Touches on the walkthrough!

Have feedback? Share your thoughts on our Discord thread!


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@leoguillaume leoguillaume force-pushed the 592-document-add-postpatchdelete-v1chunks branch 2 times, most recently from 3170632 to f3b7959 Compare January 29, 2026 18:37
@leoguillaume leoguillaume force-pushed the 592-document-add-postpatchdelete-v1chunks branch from f3b7959 to 845690e Compare January 29, 2026 19:10
Comment on lines +369 to +376
await self._upsert(
collection_id=collection_id,
document_id=document_id,
document_name=document_name,
chunks=chunks,
redis_client=redis_client,
postgres_session=postgres_session,
model_registry=model_registry,
request_context=request_context,
)

Check failure

Code scanning / CodeQL

Wrong number of arguments in a call Error

Call to
method DocumentManager._upsert
with too few arguments; should be no fewer than 10.

Copilot Autofix

AI 4 days ago

To fix the problem, the call to _upsert must supply all required arguments, specifically elasticsearch_vector_store and elasticsearch_client. The _upsert method signature is already correct and makes use of these parameters when performing the final upsert into Elasticsearch, so we should not change the method definition or remove its parameters. Instead, we update the _vectorize (or equivalent) method around line 333–382 to pass the two missing keyword arguments when invoking _upsert. Both elasticsearch_vector_store and elasticsearch_client are already in scope in this method (they are used at line 354 to compute last_chunk_id), so we simply forward them to _upsert. No new imports or definitions are needed; this is a straightforward addition of two keyword arguments at the call site, preserving existing functionality.

Concretely, in api/helpers/_documentmanager.py, in the block starting at line 366 where await self._upsert( is called, add elasticsearch_vector_store=elasticsearch_vector_store, and elasticsearch_client=elasticsearch_client, to the argument list, aligning with the parameters declared in _upsert at line 520.

Suggested changeset 1
api/helpers/_documentmanager.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/api/helpers/_documentmanager.py b/api/helpers/_documentmanager.py
--- a/api/helpers/_documentmanager.py
+++ b/api/helpers/_documentmanager.py
@@ -373,6 +373,8 @@
                 postgres_session=postgres_session,
                 model_registry=model_registry,
                 request_context=request_context,
+                elasticsearch_vector_store=elasticsearch_vector_store,
+                elasticsearch_client=elasticsearch_client,
             )
         except Exception as e:
             raise VectorizationFailedException(detail=f"Vectorization failed: {e}")
EOF
@@ -373,6 +373,8 @@
postgres_session=postgres_session,
model_registry=model_registry,
request_context=request_context,
elasticsearch_vector_store=elasticsearch_vector_store,
elasticsearch_client=elasticsearch_client,
)
except Exception as e:
raise VectorizationFailedException(detail=f"Vectorization failed: {e}")
Copilot is powered by AI and may make mistakes. Always verify output.
@leoguillaume leoguillaume force-pushed the 592-document-add-postpatchdelete-v1chunks branch from 845690e to ffda2ec Compare January 29, 2026 19:45
)
raise VectorizationFailedException(detail=f"Vectorization failed: {e}")
if file:
chunks = [InputChunk(id=i, content=chunk, metadata=metadata) for i, chunk in enumerate(chunks)]

Check failure

Code scanning / CodeQL

Potentially uninitialized local variable Error

Local variable 'chunks' may be used before it is initialized.

Copilot Autofix

AI 4 days ago

In general, this pattern is fixed by ensuring the local variable is initialized on all code paths before any possible use. That can be done by either (a) initializing it to a default value before any conditional branches, or (b) restructuring the code so that any reads are strictly dominated by the write (for example, by nesting the later logic inside the same if block).

Here, the least intrusive fix that preserves existing behavior is to initialize chunks to an empty list before the if file: block. Because all uses of chunks are inside if file: blocks, this will not change behavior: when file is truthy, chunks will be overwritten by the parsed/split content as before; when file is falsy, the lower if file: will skip the entire vectorization branch, and the initial empty list will never be used. To implement this, add chunks: list[str] = [] (or simply chunks = []) immediately after computing document_name and before the if file: block in api/helpers/_documentmanager.py.

No new imports or helper methods are required; we only add one local initialization line.

Suggested changeset 1
api/helpers/_documentmanager.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/api/helpers/_documentmanager.py b/api/helpers/_documentmanager.py
--- a/api/helpers/_documentmanager.py
+++ b/api/helpers/_documentmanager.py
@@ -189,6 +189,7 @@
 
         # get document name
         document_name = name or file.filename if file else name
+        chunks: list[str] = []
 
         if file:
             # parse the file
EOF
@@ -189,6 +189,7 @@

# get document name
document_name = name or file.filename if file else name
chunks: list[str] = []

if file:
# parse the file
Copilot is powered by AI and may make mistakes. Always verify output.
@leoguillaume leoguillaume force-pushed the 592-document-add-postpatchdelete-v1chunks branch from ffda2ec to 4a93330 Compare January 30, 2026 07:49
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.

[document] Add POST/PATCH/DELETE /v1/chunks

2 participants