apache / camel-karavan

Apache Camel Karavan a Low-code Data Integration Platform
https://camel.apache.org
Apache License 2.0
388 stars 133 forks source link

Karavan kamelet loader fails to load with Windows line endings #1259

Closed g051051 closed 1 month ago

g051051 commented 2 months ago

Describe the bug

I'm using Dirigible, which includes the Karavan Designer. When the project is checked out under Windows and built, the editor fails to start due to YAMLException: expected a single document in the stream, but found more. This was tracked into the code that loads the kamelets.yaml file. It has an expression like this: n[0].split("\n---\n").map((function(e) { This is attempting to split the YAML sub-documents and feed them into the saveKamelets function. However, if the files were checked out on Windows with core.autocrlf set to true, git will change the line ending to be Windows style CR/LF instead of LF. This breaks the split call, the entire file is passed to saveKamelets, and the editor crashes with a blank error toast.

Steps to reproduce the behavior

  1. Check out dirigible 10.4.1 on Windows with git core.autocrlf set to true.
  2. Build and run it.
  3. Create a project.
  4. Create a .camel file in the project.
  5. Double-click to open it.

Variant

Web Application

Container Management (if applicable)

None

Operating System (if applicable)

Windows

Version

4.4.0

Relevant log output

No response

mgubaidullin commented 1 month ago

If you are using Dirigible, then you better ask Dirigible. Karavan Designer is supposed to be used in Karavan VS Code Extension of in Karavan Application.

g051051 commented 1 month ago

The issue is with the line handling, because it's essentially hard-coded to assume "\n". Dirigible is just packaging the generated Karavan release as a bundle. This issue occurs regardless of whether Dirigible is involved or not, since it's related to a specific choice in the kamelet loader.