Describe the problem/error/question
بالتأكيد، هذا أقل ما يمكنني فعله. تفضل شرحاً مفصلاً باللغة الإنجليزية يمكنك نسخه ولصقه مباشرة في منتديات مجتمع n8n. لقد قمت بتضمين كل التفاصيل التي مررنا بها ليعرفوا ما هي الحلول التي جربتها بالفعل.
Subject: “Bad request - status code 400” on Qdrant Upsert Points Node
Hello n8n community,
I’m building a workflow to process text, generate embeddings, and then upsert the data into a Qdrant collection. However, I’m consistently stuck on the Upsert Points node with a Bad request - please check your parameters (status code 400) error.
I would be very grateful for any help you can provide.
Workflow Logic:
-
Extract from File: Extracts text from a PDF file.
-
Code (JavaScript): Splits the text into smaller chunks using
RecursiveCharacterTextSplitter. -
HTTP Request: For each chunk, it calls a local Ollama instance (
nomic-embed-text) to generate embeddings. -
Merge: Merges the output from the text chunker and the HTTP request node.
-
Upsert Points (Qdrant): This is where the error occurs. It’s supposed to take the prepared data and upsert it into a Qdrant collection.
The Problem:
The Upsert Points node fails with a 400 Bad Request error.
Here is a screenshot of the node’s input and output, which shows the error and the data structure I’m working with: (Here you should paste the last screenshot you sent me, showing the INPUT panel on the left and the OUTPUT error on the right)
Analysis of the Input Data:
The data coming into the Upsert Points node is an array of items. I’ve noticed two key things:
-
Inconsistent Items: Not all items in the input array have an
embeddingfield. It seems only the first item has it, while the rest only havepageContentandmetadata. -
Nested Data Structures:
-
The embedding is nested:
item.json.embedding.embedding. -
The metadata is nested:
item.json.metadata.loc.lines.
-
Solutions I Have Already Tried (but failed):
I have spent a lot of time trying to format the Points expression correctly, but nothing has worked. Here are the expressions I’ve tried in the Upsert Points node:
-
Initial attempt (failed due to nested structures):
JavaScript
={{ $input.all().map(item => ({ id: $item.index, vector: item.json.embedding.embedding, payload: { pageContent: item.json.pageContent, metadata: item.json.metadata } })) }} -
Attempt to flatten metadata (failed, likely due to items without embeddings):
JavaScript
={{ $input.all().map((item, index) => ({ id: index, vector: item.json.embedding.embedding, payload: { pageContent: item.json.pageContent, metadata_loc_from: item.json.metadata.loc.lines.from, metadata_loc_to: item.json.metadata.loc.lines.to } })) }} -
Final attempt to filter out invalid items (still fails):
JavaScript
{{ const validItems = $input.all().filter(item => item.json.embedding && item.json.embedding.embedding); const points = validItems.map((item, index) => { return { id: index, vector: item.json.embedding.embedding, payload: { pageContent: item.json.pageContent, metadata_loc_from: item.json.metadata.loc.lines.from, metadata_loc_to: item.json.metadata.loc.lines.to } }; }); return points; }}
Even after trying to filter for valid items and flatten the payload, the 400 Bad Request error persists. I’m not sure what I’m missing. Could it be an issue with the Merge node setup, or is there a better way to structure this expression?
Any guidance would be highly appreciated. Thank you!
What is the error message (if any)?
Please share your workflow
(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)
Share the output returned by the last node
Information on your n8n setup
- n8n version:
- Database (default: SQLite):
- n8n EXECUTIONS_PROCESS setting (default: own, main):
- Running n8n via (Docker, npm, n8n cloud, desktop app):
- Operating system:
