Claus Ibsen created CAMEL-26228:
-----------------------------------

             Summary: camel-neo4j - CREATE_NODE with no body and a similarity 
search with a List or text vector fail with a NullPointerException, and a 
Cypher retrieve needs a node first column
                 Key: CAMEL-26228
                 URL: https://issues.apache.org/jira/browse/CAMEL-26228
             Project: Camel
          Issue Type: Bug
          Components: camel-neo4j
            Reporter: Claus Ibsen
             Fix For: 4.24.0


Found while adding the catalog body types of neo4j (CAMEL-24961, PR #28398).

h4. 1. CREATE_NODE with no body: bare NullPointerException

{{Neo4jProducer.createNode}} (main 2a465aa4814c, line 137) builds 
{{Map.of("props", body)}}, which throws a NullPointerException when the body is 
null. Checked on 4.24.0-SNAPSHOT with Neo4j from test-infra (docker).

Proposed: fail with a clear message that CREATE_NODE needs a Map or JSON body.

h4. 2. VECTOR_SIMILARITY_SEARCH with a List<Double> or text vector

{{similaritySearch}} (line 417) converts the body with 
{{getBody(float[].class)}}. A {{List<Double>}} gives a misleading conversion 
error, and text such as {{0.75,0.65}} converts to null, so {{Map.of(..., 
"embeddingValue", vectors, ...)}} (line 433) throws a NullPointerException. 
Checked on 4.24.0-SNAPSHOT with Neo4j from test-infra (docker).

Proposed: accept a List of numbers, and fail with a clear message when the body 
is not a vector.

h4. 3. A Cypher retrieve fails when the first column is not a node

{{nodeProperties}} (line 251) maps every record with 
{{record.get(0).asNode()}}, so {{RETRIEVE_NODES_AND_UPDATE_WITH_CYPHER_QUERY}} 
with a query that returns a property, a count or a path first fails with 
"Cannot coerce STRING to Node". Checked on 4.24.0-SNAPSHOT with Neo4j from 
test-infra (docker).

Proposed: return the record as a Map when the first column is not a node.

h4. 4. The similarity search drops the score

The query (lines 426-431) yields {{node, score}}, but {{nodeProperties}} keeps 
only the node properties, so the score of each hit is lost. Checked on 
4.24.0-SNAPSHOT with Neo4j from test-infra (docker).

Proposed: add the score to each result Map (or to a header).

h4. 5. Header metadata is wrong

In {{Neo4jHeaders}}: {{CamelNeo4jQueryResultListNeo4jNodes}} (line 43) is 
described as "Query execution time in Milliseconds" but holds the list of 
records (Neo4jProducer line 242); {{CamelNeo4jQueryResultRetrieveSize}} (line 
41) is declared Long but the producer sets an Integer (line 241); the 
{{CamelNeo4jLabel}} header (line 47) and the {{query}} endpoint option 
({{Neo4jConfiguration}} line 242) are never read. Read in the code, not run.

Proposed: fix the descriptions and types, and use (or remove) the unused header 
and option.

_Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to