Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipe using simple language expressions causing failure #4777

Closed
christophd opened this issue Sep 29, 2023 · 5 comments
Closed

Pipe using simple language expressions causing failure #4777

christophd opened this issue Sep 29, 2023 · 5 comments

Comments

@christophd
Copy link
Contributor

What happened?

When a Pipe uses a simple language expression (e.g. ${header[foo]}) to set a property value on a Kamelet (e.g. on insert-header-action Kamelet) the Pipe fails because of property resolving errors.

Many Kamelets do support simple language expressions and this includes insert-header-action Kamelet but the simple language syntax ${...} causes problems in property resolving mechanism on Camel K.

In general user defined properties on Kamelets are handled as user.properties on the Integration and the ${...} simple language expression syntax collides with the general property resolving syntax.

This issue is only when running Pipes with Camel K. Camel JBang does not report these errors.

The workaround for this is to use $simple{...} expression syntax in Pipes when using Camel K.

Steps to reproduce

Use something like this in Pipe:

    - ref:
        kind: Kamelet
        apiVersion: camel.apache.org/v1
        name: insert-header-action
      properties:
        name: kafka.OVERRIDE_TOPIC
        value: ${header[topic]}

This workaround works as expected:

    - ref:
        kind: Kamelet
        apiVersion: camel.apache.org/v1
        name: insert-header-action
      properties:
        name: kafka.OVERRIDE_TOPIC
        value: $simple{header[topic]}

Relevant log output

Caused by: java.lang.IllegalArgumentException: Property with key [value] not found in properties from text: {{value}}
	at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.getPropertyValue(DefaultPropertiesParser.java:369)
	at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.readProperty(DefaultPropertiesParser.java:232)
	at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.doParseNested(DefaultPropertiesParser.java:169)
	at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.parse(DefaultPropertiesParser.java:118)
	at org.apache.camel.component.properties.DefaultPropertiesParser.parseUri(DefaultPropertiesParser.java:70)
	at org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:315)
	at org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:170)
	at org.apache.camel.impl.engine.DefaultCamelContextExtension.resolvePropertyPlaceholders(DefaultCamelContextExtension.java:230)
	at org.apache.camel.impl.engine.AbstractCamelContext.resolvePropertyPlaceholders(AbstractCamelContext.java:1566)
	at org.apache.camel.support.CamelContextHelper.parseText(CamelContextHelper.java:374)
	at org.apache.camel.reifier.AbstractReifier.parseString(AbstractReifier.java:58)
	at org.apache.camel.reifier.language.ExpressionReifier.createExpression(ExpressionReifier.java:161)
	at org.apache.camel.reifier.AbstractReifier.createExpression(AbstractReifier.java:119)
	at org.apache.camel.reifier.SetBodyReifier.createProcessor(SetBodyReifier.java:34)
	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)


### Camel K version

2.0.1
@christophd christophd added the kind/bug Something isn't working label Sep 29, 2023
@squakez
Copy link
Contributor

squakez commented Sep 29, 2023

I think this is due to #4618 - we need to let Camel framework to manage Kamelets OOTB, with its internal mechanism of replacements, loading, etc... while working on that one, we can make sure also this issue is addressed.

@gansheer
Copy link
Contributor

Out of curiosity, heve you tried something like $${header[topic]} or \\${header[topic]} ?

@squakez squakez removed the kind/bug Something isn't working label Oct 6, 2023
@squakez
Copy link
Contributor

squakez commented Oct 6, 2023

Not a bug. This is a side effect of the need to provide a placeholder in the route which will be later resolved with a configuration property. We should understand the mechanism replacement adopted by JBang and try to mimick it if that is feasible.

@christophd
Copy link
Contributor Author

@squakez how could this not be a bug? ${header[topic]} is a fully valid simple language expression in Camel. Users do not care about how Camel K internally uses configuration property replacement.

Anyway, as you said, we need to see how JBang runtime does it and fix/add support for this simple language expressions when using Pipes in Camel K

Copy link
Contributor

github-actions bot commented Jan 8, 2024

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 github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants