Claus Ibsen created CAMEL-26213:
-----------------------------------

             Summary: camel-chatscript - the first message of a conversation is 
never sent, and the reply drops every header
                 Key: CAMEL-26213
                 URL: https://issues.apache.org/jira/browse/CAMEL-26213
             Project: Camel
          Issue Type: Bug
          Components: camel-ai
            Reporter: Claus Ibsen
             Fix For: 4.24.0


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

h4. 1. The first message of an endpoint, and of each resetChat, is never sent

{{ChatScriptBot.sendChat(ChatScriptMessage)}} (main 2a465aa4814c, line 58) 
calls {{init(input)}} while not initialized; {{init}} (line 88) sends a message 
with a null body, which goes out as the literal text {{null}}, and returns the 
bot's greeting as the reply. The user's message is dropped. With 
{{resetChat=true}} {{reset}} clears {{initialized}} (line 102), so every 
message is dropped and every reply is the greeting. Checked on 4.24.0-SNAPSHOT 
with a fake socket server and the camel-test-infra ChatScript image.

Proposed: after {{init}}, send the user's message too (or send it as the volley 
that starts the conversation), and send an empty text instead of {{null}}.

h4. 2. The producer drops every header

{{ChatScriptProducer.process}} (line 58) uses 
{{exchange.getOut().setBody(inputMessage)}}, so the headers of the incoming 
message are lost after the call. Checked on 4.24.0-SNAPSHOT with a fake socket 
server.

Proposed: use {{exchange.getMessage().setBody(...)}}.

h4. 3. resetChat resets the endpoint's user, not the message's user

{{ChatScriptBot.reset}} (line 101) sends {{:reset}} as {{this.userName}} (the 
{{chatUserName}} option, often empty) and not as the user name of the message, 
so the conversation of the message's user is not reset. Checked on 
4.24.0-SNAPSHOT with the camel-test-infra ChatScript image.

Proposed: reset the conversation of the message's user (after the body is 
parsed).

h4. 4. sendChat(String) calls init(null)

{{ChatScriptBot.sendChat(String)}} (line 50) calls {{init(null)}}, and {{init}} 
reads {{input.getUserName()}}: a {{NullPointerException}}. The method is not 
used by the component. Read in the code, not run.

Proposed: build the message first and pass it to {{init}}, or remove the method.

_Claude Code on behalf of davsclaus_



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

Reply via email to