[
https://issues.apache.org/jira/browse/CAMEL-18576?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17616429#comment-17616429
]
Marco Martins edited comment on CAMEL-18576 at 10/12/22 1:45 PM:
-----------------------------------------------------------------
[~davsclaus] I don't see the `{{` pattern appear often on ES queries since
they're JSON payloads and JSON can't have two `{{`, although, they could appear
as a field value to be searched.
This issue occurred without the \{{ since Camel was looking for }} pattern
which occurs very often in JSON, and if found it would consider that it was a
property placeholder and when looking for the beginning of the "false property"
it would not find it since there was no `{{`.
was (Author: JIRAUSER296449):
[~davsclaus] I don't see the `{{` pattern appear often on ES queries since
they're JSON payloads and JSON can't have two `{{`, although, they could appear
as a field value to be searched.
This issue occurred without the {{since Camel was looking for }} pattern which
occurs very often in JSON, and if found it would consider that it was a
property placeholder and when looking for the beginning of the "false property"
it would not find it since there was no `{{`.
> 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)