camel-k icon indicating copy to clipboard operation
camel-k copied to clipboard

Dependencies not added automatically when using dataformats

Open lsergio opened this issue 1 year ago • 5 comments

What happened?

When I created an integration that included the following step:

steps:
- marshal:
    base64: {}

Camel-K didn't include the camel-base64 dependency automatically and it only worked after I included it explicitly in the dependencies section of the spec.

I see that for languages it does so, like in this example:

when:
- expression:
    jq:
      expression: '.store.book.price < 30'    

where the use of jq caused the required dependencies for it to work to be added automatically to the Integration classpath.

I'm assuming dataformats should work like expression languages, and that's the reason I'm opening a bug. If this is by design, please just close it.

Steps to reproduce

No response

Relevant log output

No response

Camel K version

2.2.0

lsergio avatar Jun 20 '24 17:06 lsergio

cc @christophd

squakez avatar Jun 21 '24 08:06 squakez

@lsergio I understand this is affecting when you're adding a Kamelet, right?

squakez avatar Jun 21 '24 08:06 squakez

No, this actually happened with a plain k8s Integration:

apiVersion: camel.apache.org/v1
kind: Integration
metadata:
  name: base64test
spec:
  sources:
  - name: main.yaml
    content: |-
      - from:
          uri: "rest:get:/base64"
          steps:
          - marshal:
              base64: {}
          - log:
              message: "Result: ${body}"

The Integration builds, but fails to start with the error:

Caused by: java.lang.IllegalArgumentException: Data format 'base64' could not be created. Ensure that the data format is valid and the associated Camel component is present on the classpath
	at org.apache.camel.reifier.dataformat.DataFormatReifier.createDataFormat(DataFormatReifier.java:279)
	at org.apache.camel.reifier.dataformat.DataFormatReifier.getDataFormat(DataFormatReifier.java:152)
	at org.apache.camel.reifier.dataformat.DataFormatReifier.getDataFormat(DataFormatReifier.java:112)
	at org.apache.camel.reifier.MarshalReifier.createProcessor(MarshalReifier.java:35)
	at org.apache.camel.reifier.ProcessorReifier.makeProcessor(ProcessorReifier.java:853)
	at org.apache.camel.reifier.ProcessorReifier.addRoutes(ProcessorReifier.java:593)
	at org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:213)
	... 31 more

Adding:

  dependencies:
  - "camel:base64"

causes a new kit to be built and solves the issue.

lsergio avatar Jun 21 '24 11:06 lsergio

Ah, okey. Sorry @christophd I added a mention to you thinking it was related to Kamelets. Thans @lsergio for clarification. Then, I think this is falling under the more general problem described in #527. We discussed some possibility to enhance that by making use of Camel JBang, but, so far, no outcome. If you want, you can try fixing this by adding the parsing in our code. Look at this reference implementation https://github.com/apache/camel-k/pull/3312 as it does not seem particularly complex to develop.

squakez avatar Jun 21 '24 12:06 squakez

This issue has been automatically marked as stale due to 90 days of inactivity. It will be closed if no further activity occurs within 15 days. If you think that’s incorrect or the issue should never stale, please simply write any comment. Thanks for your contributions!

github-actions[bot] avatar Sep 20 '24 00:09 github-actions[bot]