You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Nicolas Filotto (Jira)" <ji...@apache.org> on 2022/10/11 18:10:00 UTC

[jira] [Comment Edited] (CAMEL-18576) kamelets - JSon Property value can't finish with }}

    [ https://issues.apache.org/jira/browse/CAMEL-18576?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17616013#comment-17616013 ] 

Nicolas Filotto edited comment on CAMEL-18576 at 10/11/22 6:09 PM:
-------------------------------------------------------------------

[~davsclaus] I proposed in this PR [https://github.com/apache/camel/pull/8521] a fix based on an escape character (backslash) WDYT? 

 

PS: Sorry to work on your ticket, initially, I just wanted to test an idea. 


was (Author: JIRAUSER285918):
[~davsclaus] I proposed in this PR https://github.com/apache/camel/pull/8521 a fix based on an escape character (backslash) WDYT? 

> kamelets - JSon Property value can't finish with }}
> ---------------------------------------------------
>
>                 Key: CAMEL-18576
>                 URL: https://issues.apache.org/jira/browse/CAMEL-18576
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>            Reporter: Marco Martins
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 3.20.0
>
>
> Hi, I'm using Quarkus Camel 2.12.3.Final with YAML DSL and Kamelets and I have a problem passing a JSON value through URI as a query parameter when trying to use the [elasticsearch-search-source|https://github.com/apache/camel-kamelets/blob/main/kamelets/elasticsearch-search-source.kamelet.yaml] with a basic query:
> {code:json}
> {"query":{"match_all":{}}} {code}
> Example on the YAML DSL:
>  * Scenario 1
> {code:yaml}
> query: '{"query":{"match_all":{}}}'{code}
> Gives
> {noformat}
> java.lang.IllegalArgumentException: Missing {{ from the text: {"query":{"match_all":{}}}
> {noformat}
>  * Scenario 2
> {code:yaml}
> query: '{{myQuery}}'{code}
> Gives
> {noformat}
> java.lang.IllegalArgumentException: Missing {{ from the text: {"query":{"match_all":{}}}
> {noformat}
>  * Scenario 3
> {code:yaml}
> query: '#property:myQuery'{code}
> Gives
> {noformat}
> java.lang.IllegalArgumentException: Property with key myQuery not found by properties component
> {noformat}
> But using debug I've checked that the above exception occurs due to the same
> {noformat}
> java.lang.IllegalArgumentException: Missing {{ from the text: {"query":{"match_all":{}}}
> {noformat}
>  * Scenario 4
> I've also tried to change the Kamelet YAML definition to use the RAW value directly
> {code:yaml}
> - set-body: 
>   constant: "RAW({{myQuery}})"{code}
> With the same result
> {noformat}
> java.lang.IllegalArgumentException: Missing {{ from the text: {"query":{"match_all":{}}}
> {noformat}
> I have a workaround if I add spaces in JSON like below it works in scenarios 1 and 2.
> {code:json}
> { "query": { "match_all": { } } } {code}
> My point is, why do I have to change the JSON value to adapt to the Camel parser? Also, there also might exist some other use case where the value can't be changed.
> Why don't you simply have a function that does not try to resolve properties as placeholders recursively? For example:
> {code:yaml}
> query: '{{raw:myQuery}}'{code}
> Or with a default value
> {code:yaml}
> query: '{{raw:myQuery:{"query":{"match_all":{}}}}}'{code}
> Or at least have a way to escape curly brackets.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)