davsclaus opened a new pull request, #29830:
URL: https://github.com/apache/camel/pull/29830

   ## Summary
   
   An item of [CAMEL-26911](https://issues.apache.org/jira/browse/CAMEL-26911): 
**a tool could read half the answer of an action.**
   
   The CLI connector of an integration answers an action (`camel cmd ...`, 
`camel get ...`, the AI and MCP tools, the TUI) by writing a file that the CLI 
polls for. The connector wrote the answer in place (`IOHelper.writeText`), and 
the CLI took any text that was not blank: `ActionClient.executeText`, which 
hands the answer on as text to the AI and MCP tools, could return a truncated 
JSON. The readers that parse the answer already waited for one that parses. The 
status file was already written aside and moved in place; the answers and the 
other snapshot files were not.
   
   ### Fix
   
   - Connector: the answer of an action, and the debug, message history, error 
and timeline files that it rewrites whole, are written to a `.tmp` file and 
moved in place (atomically where the file system can), as the status file. The 
`.tmp` files go when the connector stops.
   - CLI: `ActionClient.executeText` returns an answer that looks like JSON 
once it parses, so also an integration of an earlier Camel version, which 
writes in place, gives a whole answer. Other text (the API hands on what the 
integration wrote, `RuntimeHelperTest`) is returned once it reads the same at 
two polls.
   
   Not changed: the trace and receive files, which the connector appends to and 
the CLI follows line by line.
   
   ## Tests
   
   - `ActionClientTest.textOfAnAnswerIsReadWhenItIsAllThere`: an integration 
that writes half an answer first: the text is the whole answer. Without the fix 
it is `{"status":"success","`.
   - `FileCliConnectorTransportTest.resultIsTheReply`: no `.tmp` file is left 
of an answer.
   - camel-cli-connector (111 tests) and camel-jbang-core pass locally.
   
   _Claude Code on behalf of Claus Ibsen (davsclaus)_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_012nJsFsjqqFiwroeHRWaKbS
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to