Claus Ibsen created CAMEL-26210:
-----------------------------------
Summary: camel-spring-ai-vector-store - DELETE deletes the ids a
previous ADD or SIMILARITY_SEARCH put in the header, and ADD stores a float[]
body as text
Key: CAMEL-26210
URL: https://issues.apache.org/jira/browse/CAMEL-26210
Project: Camel
Issue Type: Bug
Components: camel-spring-ai
Reporter: Claus Ibsen
Fix For: 4.24.0
Found while adding the catalog body types of spring-ai-vector-store
(CAMEL-24961, PR #28401).
h4. 1. DELETE reads the DocumentIds header that ADD and SIMILARITY_SEARCH set
{{SpringAiVectorStoreProducer.processDelete}} (main 2a465aa4814c, line 164)
reads {{CamelSpringAiVectorStoreDocumentIds}} before the body; ADD (line 143)
and SIMILARITY_SEARCH (line 247) set that header. A later DELETE in the same
route deletes those ids instead of the ids in the body, for example everything
a search just found. Checked on 4.24.0-SNAPSHOT with a {{SimpleVectorStore}}.
Proposed: read the ids from the body first, or use a separate input header from
the output one.
h4. 2. ADD with a float[] body and no input-text header stores "[F@..."
Without {{CamelSpringAiEmbeddingInputText}}, a {{float[]}} body reaches the
last branch (line 123) and is stored as a Document with the text of
{{float[].toString()}}. Checked on 4.24.0-SNAPSHOT with a {{SimpleVectorStore}}.
Proposed: fail when the body is a vector without the input text.
h4. 3. SIMILARITY_SEARCH after spring-ai-embeddings searches with
float[].toString()
{{processSimilaritySearch}} (line 205) uses {{getBody(String.class)}} as the
query, so after spring-ai-embeddings (body {{float[]}}) it searches for the
text of {{float[].toString()}}; the {{CamelSpringAiEmbeddingInputText}} header
with the original text is ignored. Checked on 4.24.0-SNAPSHOT with a
{{SimpleVectorStore}}.
Proposed: use the input-text header (or fail) when the body is a vector.
h4. 4. A leftover CamelSpringAiEmbeddingInputText header makes ADD ignore the
body
In {{processAdd}} (lines 79-82) the input-text header wins over any body, so
after one spring-ai-embeddings call an ADD of a {{Document}} or text body later
in the route stores the old header text instead. Checked on 4.24.0-SNAPSHOT
with a {{SimpleVectorStore}}.
Proposed: use the header only together with a vector body (the case of line 75).
h4. 5. ADD with a List of Map drops every element, then fails
Lines 113-121 keep only {{Document}} and {{String}} elements and skip the rest
without a message; a List of Maps leaves an empty list and {{vectorStore.add}}
fails with "Documents list cannot be empty". Checked on 4.24.0-SNAPSHOT with a
{{SimpleVectorStore}}.
Proposed: fail with a message that names the unsupported element type (or
convert a Map with text/metadata keys).
h4. 6. DELETE DocumentsDeleted counts the ids asked, not deleted
Line 180 sets {{CamelSpringAiVectorStoreDocumentsDeleted}} to
{{documentIds.size()}}, also for ids that do not exist. Checked on
4.24.0-SNAPSHOT with a {{SimpleVectorStore}}.
Proposed: document it as the number of ids requested (the VectorStore API does
not return a count).
_Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)