[GH-ISSUE #3793] [BUG]: Cannot Pin Documents Embedded Through The API #2431

Closed
opened 2026-02-22 18:29:39 -05:00 by yindo · 5 comments
Owner

Originally created by @fffe0d0a on GitHub (May 9, 2025).
Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/3793

How are you running AnythingLLM?

AnythingLLM desktop app

What happened?

This is for version 1.8.1-r2 of the desktop UI.

When attempting to pin a document to a workspace using the API, I am constantly met with 404 responses.
Documents that I upload to a workspace using the API do not appear as embedded in the desktop UI, nor do they appear in the documents json property of some API responses.

While the documents are vectorised and accessable by a workspace's model, this issue appears to have the effect of preventing these documents from being pinned to the workspace.

Are there known steps to reproduce?

We can reproduce this bug using the Swagger API documentation UI, though calls from external tools reproduce the same issue.

  1. Create a workspace named "debug-workspace" with /v1/workspace/new
  2. Upload a document named "!debug!.txt" containing "hello world" with /v1/document/upload/debug-dir
  3. Embed the document with /v1/workspace/debug-workspace/update-embeddings

By using the desktop UI, we can see there is now 1 vector in the database.
Querying the workspace's model shows it is aware of the content of !debug!.txt.
However, by using the document upload UI in the desktop UI, no files are shown as embedded in the workspace.
Likewise, the "documents" property of the json response that /update-embeddings returns is empty.

  1. Pin the embedded document with /v1/workspace/debug-workspace/update-pin

Expected: Document is pinned to the workspace
Actual: API returns a 404 as if the document does not exist

Now, we manually upload "!debug!2.txt" to the workspace using the desktop UI.
This document is shown as embedded in both the desktop UI and in the documents property of some workspace related API calls.
Yet the original "!debug!.txt" is still not shown anywhere.

Originally created by @fffe0d0a on GitHub (May 9, 2025). Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/3793 ### How are you running AnythingLLM? AnythingLLM desktop app ### What happened? This is for version 1.8.1-r2 of the desktop UI. When attempting to pin a document to a workspace using the API, I am constantly met with 404 responses. Documents that I upload to a workspace using the API do not appear as embedded in the desktop UI, nor do they appear in the documents json property of some API responses. While the documents are vectorised and accessable by a workspace's model, this issue appears to have the effect of preventing these documents from being pinned to the workspace. ### Are there known steps to reproduce? We can reproduce this bug using the Swagger API documentation UI, though calls from external tools reproduce the same issue. 1. Create a workspace named "debug-workspace" with /v1/workspace/new 2. Upload a document named "!debug!.txt" containing "hello world" with /v1/document/upload/debug-dir 3. Embed the document with /v1/workspace/debug-workspace/update-embeddings By using the desktop UI, we can see there is now 1 vector in the database. Querying the workspace's model shows it is aware of the content of !debug!.txt. However, by using the document upload UI in the desktop UI, no files are shown as embedded in the workspace. Likewise, the "documents" property of the json response that /update-embeddings returns is empty. 4. Pin the embedded document with /v1/workspace/debug-workspace/update-pin **Expected: Document is pinned to the workspace Actual: API returns a 404 as if the document does not exist** Now, we manually upload "!debug!2.txt" to the workspace using the desktop UI. This document is shown as embedded in both the desktop UI and in the documents property of some workspace related API calls. Yet the original "!debug!.txt" is still not shown anywhere.
yindo added the possible bug label 2026-02-22 18:29:39 -05:00
yindo closed this issue 2026-02-22 18:29:39 -05:00
Author
Owner

@fffe0d0a commented on GitHub (May 9, 2025):

I should add, using /v1/document/upload with the addToWorkspace property set to the relevent workspace seems to avoid this issue from happening. I beleive the issue may be due to /v1/workspace/{slug}/update-embeddings not "adding" the document to the workspace, which I suspect is unintentional. Either that, or I am misinterpreting the intended workflow.

@fffe0d0a commented on GitHub (May 9, 2025): I should add, using /v1/document/upload with the _addToWorkspace_ property set to the relevent workspace seems to avoid this issue from happening. I beleive the issue may be due to /v1/workspace/{slug}/update-embeddings not "adding" the document to the workspace, which I suspect is unintentional. Either that, or I am misinterpreting the intended workflow.
Author
Owner

@fffe0d0a commented on GitHub (May 9, 2025):

I can add the issue also occurs with /v1/document/upload/{folder} even if addToWorkspaces is set. The 'documents' property is populated with valid information in the response, yet the file does not show in the desktop UI, nor is the file pinnable.

@fffe0d0a commented on GitHub (May 9, 2025): I can add the issue also occurs with /v1/document/upload/{folder} even if _addToWorkspaces_ is set. The 'documents' property is populated with valid information in the response, yet the file does not show in the desktop UI, nor is the file pinnable.
Author
Owner

@timothycarambat commented on GitHub (May 9, 2025):

The issue is very confusing - are you using the UI to embed content or the API. The issue seems to mention the UI a lot and I'm not even sure how to approach what exactly the issue you are encountering or this is two separate issues you are encountering?

What, if anything, specifically is going on with the UI upload process?

What specifically with the API is going wrong? Its worth mentioning that the swagger UI does not work with file uploads - so in that case the code should used here to upload documents.

@timothycarambat commented on GitHub (May 9, 2025): The issue is very confusing - are you using the UI to embed content or the API. The issue seems to mention the UI a lot and I'm not even sure how to approach what exactly the issue you are encountering or this is two separate issues you are encountering? What, if anything, specifically is going on with the UI upload process? What specifically with the API is going wrong? Its worth mentioning that the swagger UI _does not work_ with file uploads - so in that case the code should used here to upload documents.
Author
Owner

@timothycarambat commented on GitHub (May 9, 2025):

Just some more testing. I think when you say UI you are referring to the Swagger API Docs UI not the actual application UI. UI with the exact setup works fine, so you must mean swagger in that case

@timothycarambat commented on GitHub (May 9, 2025): Just some more testing. I think when you say UI you are referring to the _Swagger API Docs UI_ not the actual application UI. UI with the exact setup works fine, so you must mean swagger in that case
Author
Owner

@timothycarambat commented on GitHub (May 9, 2025):

This is something code related on your end (or simply the Swagger UI being broken for file uploads since we require multi-part files)

example script

import requests

# Create workspace
BASE_URL = "http://localhost:3001/api/v1"
API_KEY = "1WJDX2F-BW9MCJ0-MQD27QZ-VGKGJHW"
headers = {
  "Authorization": f"Bearer {API_KEY}"
}

# Create workspace
print("Creating workspace...")
response = requests.post(f"{BASE_URL}/workspace/new", json={"name": "debug-workspace"}, headers=headers)
print(response.json())
print("\n\n")
ws_slug = response.json()["workspace"]["slug"]

# Upload document
print("Uploading document...")
multi_part_form_data = {
  "file": ("!debug!.txt", open("!debug!.txt", "rb"), "text/plain")
}
response = requests.post(f"{BASE_URL}/document/upload/debug-dir", files=multi_part_form_data, headers=headers)
print(response.json())
print("\n\n")
new_doc_location = response.json()["documents"][0]["location"]

# Upload document to workspace individually.
print("Uploading document to workspace individually...")
response = requests.post(f"{BASE_URL}/workspace/{ws_slug}/update-embeddings", json={"adds": [new_doc_location]}, headers=headers)
print(response.json())
print("\n\n")

# Get all documents in workspace.
print("Getting all documents in workspace...")
response = requests.get(f"{BASE_URL}/workspace/{ws_slug}", headers=headers)
print(response.json())
print("\n\n")
# Pin the document to the workspace
print("Pinning document to workspace...")
response = requests.post(f"{BASE_URL}/workspace/{ws_slug}/update-pin", json={"docPath": new_doc_location, "pinStatus": True}, headers=headers)
print(response.json())
print("\n\n")


# Show document and pinned status.
print("Showing document and pinned status...")
response = requests.get(f"{BASE_URL}/workspace/{ws_slug}", headers=headers)
print(response.json())
print("\n\n")

Responses

Creating workspace...
{'workspace': {'id': 14, 'name': 'debug-workspace', 'slug': 'debug-workspace-97307903', 'vectorTag': None, 'createdAt': '2025-05-09T16:15:37.736Z', 'openAiTemp': None, 'openAiHistory': 20, 'lastUpdatedAt': '2025-05-09T16:15:37.736Z', 'openAiPrompt': None, 'similarityThreshold': 0.25, 'chatProvider': None, 'chatModel': None, 'topN': 4, 'chatMode': 'chat', 'pfpFilename': None, 'agentProvider': None, 'agentModel': None, 'queryRefusalResponse': None, 'vectorSearchMode': 'default'}, 'message': None}



Uploading document...
{'success': True, 'error': None, 'documents': [{'id': 'f9a2f168-0608-4f89-aa70-dbce42aba25a', 'url': 'file:///Users/tim/Library/Application Support/anythingllm-desktop/storage/hotdir/!debug!.txt', 'title': '!debug!.txt', 'docAuthor': 'Unknown', 'description': 'Unknown', 'docSource': 'a text file uploaded by the user.', 'chunkSource': '', 'published': '5/9/2025, 9:15:37 AM', 'wordCount': 2, 'pageContent': 'hello world\n', 'token_count_estimate': 3, 'location': 'debug-dir/!debug!.txt-f9a2f168-0608-4f89-aa70-dbce42aba25a.json', 'name': '!debug!.txt-f9a2f168-0608-4f89-aa70-dbce42aba25a.json'}]}



Uploading document to workspace individually...
{'workspace': {'id': 14, 'name': 'debug-workspace', 'slug': 'debug-workspace-97307903', 'vectorTag': None, 'createdAt': '2025-05-09T16:15:37.736Z', 'openAiTemp': None, 'openAiHistory': 20, 'lastUpdatedAt': '2025-05-09T16:15:37.736Z', 'openAiPrompt': None, 'similarityThreshold': 0.25, 'chatProvider': None, 'chatModel': None, 'topN': 4, 'chatMode': 'chat', 'pfpFilename': None, 'agentProvider': None, 'agentModel': None, 'queryRefusalResponse': None, 'vectorSearchMode': 'default', 'documents': [{'id': 12, 'docId': '92e74580-85b3-49b5-8fe9-ea4d4ecfbb0a', 'filename': '!debug!.txt-f9a2f168-0608-4f89-aa70-dbce42aba25a.json', 'docpath': 'debug-dir/!debug!.txt-f9a2f168-0608-4f89-aa70-dbce42aba25a.json', 'workspaceId': 14, 'metadata': '{"id":"f9a2f168-0608-4f89-aa70-dbce42aba25a","url":"file:///Users/tim/Library/Application Support/anythingllm-desktop/storage/hotdir/!debug!.txt","title":"!debug!.txt","docAuthor":"Unknown","description":"Unknown","docSource":"a text file uploaded by the user.","chunkSource":"","published":"5/9/2025, 9:15:37 AM","wordCount":2,"token_count_estimate":3}', 'pinned': False, 'watched': False, 'createdAt': '2025-05-09T16:15:38.105Z', 'lastUpdatedAt': '2025-05-09T16:15:38.105Z'}]}}



Getting all documents in workspace...
{'workspace': [{'id': 14, 'name': 'debug-workspace', 'slug': 'debug-workspace-97307903', 'vectorTag': None, 'createdAt': '2025-05-09T16:15:37.736Z', 'openAiTemp': None, 'openAiHistory': 20, 'lastUpdatedAt': '2025-05-09T16:15:37.736Z', 'openAiPrompt': None, 'similarityThreshold': 0.25, 'chatProvider': None, 'chatModel': None, 'topN': 4, 'chatMode': 'chat', 'pfpFilename': None, 'agentProvider': None, 'agentModel': None, 'queryRefusalResponse': None, 'vectorSearchMode': 'default', 'documents': [{'id': 12, 'docId': '92e74580-85b3-49b5-8fe9-ea4d4ecfbb0a', 'filename': '!debug!.txt-f9a2f168-0608-4f89-aa70-dbce42aba25a.json', 'docpath': 'debug-dir/!debug!.txt-f9a2f168-0608-4f89-aa70-dbce42aba25a.json', 'workspaceId': 14, 'metadata': '{"id":"f9a2f168-0608-4f89-aa70-dbce42aba25a","url":"file:///Users/tim/Library/Application Support/anythingllm-desktop/storage/hotdir/!debug!.txt","title":"!debug!.txt","docAuthor":"Unknown","description":"Unknown","docSource":"a text file uploaded by the user.","chunkSource":"","published":"5/9/2025, 9:15:37 AM","wordCount":2,"token_count_estimate":3}', 'pinned': False, 'watched': False, 'createdAt': '2025-05-09T16:15:38.105Z', 'lastUpdatedAt': '2025-05-09T16:15:38.105Z'}], 'threads': []}]}



Pinning document to workspace...
{'message': 'Pin status updated successfully'}



Showing document and pinned status...
{'workspace': [{'id': 14, 'name': 'debug-workspace', 'slug': 'debug-workspace-97307903', 'vectorTag': None, 'createdAt': '2025-05-09T16:15:37.736Z', 'openAiTemp': None, 'openAiHistory': 20, 'lastUpdatedAt': '2025-05-09T16:15:37.736Z', 'openAiPrompt': None, 'similarityThreshold': 0.25, 'chatProvider': None, 'chatModel': None, 'topN': 4, 'chatMode': 'chat', 'pfpFilename': None, 'agentProvider': None, 'agentModel': None, 'queryRefusalResponse': None, 'vectorSearchMode': 'default', 'documents': [{'id': 12, 'docId': '92e74580-85b3-49b5-8fe9-ea4d4ecfbb0a', 'filename': '!debug!.txt-f9a2f168-0608-4f89-aa70-dbce42aba25a.json', 'docpath': 'debug-dir/!debug!.txt-f9a2f168-0608-4f89-aa70-dbce42aba25a.json', 'workspaceId': 14, 'metadata': '{"id":"f9a2f168-0608-4f89-aa70-dbce42aba25a","url":"file:///Users/tim/Library/Application Support/anythingllm-desktop/storage/hotdir/!debug!.txt","title":"!debug!.txt","docAuthor":"Unknown","description":"Unknown","docSource":"a text file uploaded by the user.","chunkSource":"","published":"5/9/2025, 9:15:37 AM","wordCount":2,"token_count_estimate":3}', 'pinned': True, 'watched': False, 'createdAt': '2025-05-09T16:15:38.105Z', 'lastUpdatedAt': '2025-05-09T16:15:38.105Z'}], 'threads': []}]}
@timothycarambat commented on GitHub (May 9, 2025): This is something code related on your end (or simply the Swagger UI being broken for file uploads since we require multi-part files) example script ```python import requests # Create workspace BASE_URL = "http://localhost:3001/api/v1" API_KEY = "1WJDX2F-BW9MCJ0-MQD27QZ-VGKGJHW" headers = { "Authorization": f"Bearer {API_KEY}" } # Create workspace print("Creating workspace...") response = requests.post(f"{BASE_URL}/workspace/new", json={"name": "debug-workspace"}, headers=headers) print(response.json()) print("\n\n") ws_slug = response.json()["workspace"]["slug"] # Upload document print("Uploading document...") multi_part_form_data = { "file": ("!debug!.txt", open("!debug!.txt", "rb"), "text/plain") } response = requests.post(f"{BASE_URL}/document/upload/debug-dir", files=multi_part_form_data, headers=headers) print(response.json()) print("\n\n") new_doc_location = response.json()["documents"][0]["location"] # Upload document to workspace individually. print("Uploading document to workspace individually...") response = requests.post(f"{BASE_URL}/workspace/{ws_slug}/update-embeddings", json={"adds": [new_doc_location]}, headers=headers) print(response.json()) print("\n\n") # Get all documents in workspace. print("Getting all documents in workspace...") response = requests.get(f"{BASE_URL}/workspace/{ws_slug}", headers=headers) print(response.json()) print("\n\n") # Pin the document to the workspace print("Pinning document to workspace...") response = requests.post(f"{BASE_URL}/workspace/{ws_slug}/update-pin", json={"docPath": new_doc_location, "pinStatus": True}, headers=headers) print(response.json()) print("\n\n") # Show document and pinned status. print("Showing document and pinned status...") response = requests.get(f"{BASE_URL}/workspace/{ws_slug}", headers=headers) print(response.json()) print("\n\n") ``` Responses ``` Creating workspace... {'workspace': {'id': 14, 'name': 'debug-workspace', 'slug': 'debug-workspace-97307903', 'vectorTag': None, 'createdAt': '2025-05-09T16:15:37.736Z', 'openAiTemp': None, 'openAiHistory': 20, 'lastUpdatedAt': '2025-05-09T16:15:37.736Z', 'openAiPrompt': None, 'similarityThreshold': 0.25, 'chatProvider': None, 'chatModel': None, 'topN': 4, 'chatMode': 'chat', 'pfpFilename': None, 'agentProvider': None, 'agentModel': None, 'queryRefusalResponse': None, 'vectorSearchMode': 'default'}, 'message': None} Uploading document... {'success': True, 'error': None, 'documents': [{'id': 'f9a2f168-0608-4f89-aa70-dbce42aba25a', 'url': 'file:///Users/tim/Library/Application Support/anythingllm-desktop/storage/hotdir/!debug!.txt', 'title': '!debug!.txt', 'docAuthor': 'Unknown', 'description': 'Unknown', 'docSource': 'a text file uploaded by the user.', 'chunkSource': '', 'published': '5/9/2025, 9:15:37 AM', 'wordCount': 2, 'pageContent': 'hello world\n', 'token_count_estimate': 3, 'location': 'debug-dir/!debug!.txt-f9a2f168-0608-4f89-aa70-dbce42aba25a.json', 'name': '!debug!.txt-f9a2f168-0608-4f89-aa70-dbce42aba25a.json'}]} Uploading document to workspace individually... {'workspace': {'id': 14, 'name': 'debug-workspace', 'slug': 'debug-workspace-97307903', 'vectorTag': None, 'createdAt': '2025-05-09T16:15:37.736Z', 'openAiTemp': None, 'openAiHistory': 20, 'lastUpdatedAt': '2025-05-09T16:15:37.736Z', 'openAiPrompt': None, 'similarityThreshold': 0.25, 'chatProvider': None, 'chatModel': None, 'topN': 4, 'chatMode': 'chat', 'pfpFilename': None, 'agentProvider': None, 'agentModel': None, 'queryRefusalResponse': None, 'vectorSearchMode': 'default', 'documents': [{'id': 12, 'docId': '92e74580-85b3-49b5-8fe9-ea4d4ecfbb0a', 'filename': '!debug!.txt-f9a2f168-0608-4f89-aa70-dbce42aba25a.json', 'docpath': 'debug-dir/!debug!.txt-f9a2f168-0608-4f89-aa70-dbce42aba25a.json', 'workspaceId': 14, 'metadata': '{"id":"f9a2f168-0608-4f89-aa70-dbce42aba25a","url":"file:///Users/tim/Library/Application Support/anythingllm-desktop/storage/hotdir/!debug!.txt","title":"!debug!.txt","docAuthor":"Unknown","description":"Unknown","docSource":"a text file uploaded by the user.","chunkSource":"","published":"5/9/2025, 9:15:37 AM","wordCount":2,"token_count_estimate":3}', 'pinned': False, 'watched': False, 'createdAt': '2025-05-09T16:15:38.105Z', 'lastUpdatedAt': '2025-05-09T16:15:38.105Z'}]}} Getting all documents in workspace... {'workspace': [{'id': 14, 'name': 'debug-workspace', 'slug': 'debug-workspace-97307903', 'vectorTag': None, 'createdAt': '2025-05-09T16:15:37.736Z', 'openAiTemp': None, 'openAiHistory': 20, 'lastUpdatedAt': '2025-05-09T16:15:37.736Z', 'openAiPrompt': None, 'similarityThreshold': 0.25, 'chatProvider': None, 'chatModel': None, 'topN': 4, 'chatMode': 'chat', 'pfpFilename': None, 'agentProvider': None, 'agentModel': None, 'queryRefusalResponse': None, 'vectorSearchMode': 'default', 'documents': [{'id': 12, 'docId': '92e74580-85b3-49b5-8fe9-ea4d4ecfbb0a', 'filename': '!debug!.txt-f9a2f168-0608-4f89-aa70-dbce42aba25a.json', 'docpath': 'debug-dir/!debug!.txt-f9a2f168-0608-4f89-aa70-dbce42aba25a.json', 'workspaceId': 14, 'metadata': '{"id":"f9a2f168-0608-4f89-aa70-dbce42aba25a","url":"file:///Users/tim/Library/Application Support/anythingllm-desktop/storage/hotdir/!debug!.txt","title":"!debug!.txt","docAuthor":"Unknown","description":"Unknown","docSource":"a text file uploaded by the user.","chunkSource":"","published":"5/9/2025, 9:15:37 AM","wordCount":2,"token_count_estimate":3}', 'pinned': False, 'watched': False, 'createdAt': '2025-05-09T16:15:38.105Z', 'lastUpdatedAt': '2025-05-09T16:15:38.105Z'}], 'threads': []}]} Pinning document to workspace... {'message': 'Pin status updated successfully'} Showing document and pinned status... {'workspace': [{'id': 14, 'name': 'debug-workspace', 'slug': 'debug-workspace-97307903', 'vectorTag': None, 'createdAt': '2025-05-09T16:15:37.736Z', 'openAiTemp': None, 'openAiHistory': 20, 'lastUpdatedAt': '2025-05-09T16:15:37.736Z', 'openAiPrompt': None, 'similarityThreshold': 0.25, 'chatProvider': None, 'chatModel': None, 'topN': 4, 'chatMode': 'chat', 'pfpFilename': None, 'agentProvider': None, 'agentModel': None, 'queryRefusalResponse': None, 'vectorSearchMode': 'default', 'documents': [{'id': 12, 'docId': '92e74580-85b3-49b5-8fe9-ea4d4ecfbb0a', 'filename': '!debug!.txt-f9a2f168-0608-4f89-aa70-dbce42aba25a.json', 'docpath': 'debug-dir/!debug!.txt-f9a2f168-0608-4f89-aa70-dbce42aba25a.json', 'workspaceId': 14, 'metadata': '{"id":"f9a2f168-0608-4f89-aa70-dbce42aba25a","url":"file:///Users/tim/Library/Application Support/anythingllm-desktop/storage/hotdir/!debug!.txt","title":"!debug!.txt","docAuthor":"Unknown","description":"Unknown","docSource":"a text file uploaded by the user.","chunkSource":"","published":"5/9/2025, 9:15:37 AM","wordCount":2,"token_count_estimate":3}', 'pinned': True, 'watched': False, 'createdAt': '2025-05-09T16:15:38.105Z', 'lastUpdatedAt': '2025-05-09T16:15:38.105Z'}], 'threads': []}]} ```
yindo changed title from [BUG]: Cannot Pin Documents Embedded Through The API to [GH-ISSUE #3793] [BUG]: Cannot Pin Documents Embedded Through The API 2026-06-05 14:46:31 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#2431