Fix CLI document add command: send form data instead of URL parameters#152
Closed
Fix CLI document add command: send form data instead of URL parameters#152
Conversation
8 tasks
…match Co-authored-by: dawn-tran <104935595+dawn-tran@users.noreply.github.com>
… params Co-authored-by: dawn-tran <104935595+dawn-tran@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix issue where the CLI
Fix CLI document add command: send form data instead of URL parameters
Sep 6, 2025
extralit documents add --workspace priyankesh-test --reference paper-001 --file .\paper.pdf no longer works (resulting in error Error adding document: Server disconnected without sending a response.) because the add_document...
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
The CLI command
extralit documents add --workspace <workspace> --reference <ref> --file <file>was failing with the error "Server disconnected without sending a response." This prevented users from adding individual documents via the CLI.Root Cause
The issue was a mismatch between how the client sends document metadata and how the server expects to receive it:
DocumentsAPI.create()method was sending document metadata as URL parameters (params=document_payload)/api/v1/documentsendpoint expects document metadata as form fields via FastAPI'sDepends()mechanismWhen uploading files with multipart form data, this parameter/form data mismatch caused the server to fail parsing the request, resulting in a dropped connection.
Solution
Modified
DocumentsAPI.create()inextralit/src/extralit/_api/_documents.pyto send document metadata in the correct format:data=document_payload) with multipart files - compatible with FastAPIDepends()json=document_payload) - also compatible with FastAPIparams=document_payload) which were incompatibleTesting
Verified the fix works correctly for both scenarios:
The CLI command
extralit documents add --workspace priyankesh-test --reference paper-001 --file ./paper.pdfshould now work as expected.💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.