Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-18576

kamelets - JSon Property value can't finish with }}

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 3.20.0
    • camel-core
    • None
    • Unknown

    Description

      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 with a basic query:

      {"query":{"match_all":{}}} 

      Example on the YAML DSL:

      • Scenario 1
        query: '{"query":{"match_all":{}}}'

        Gives

        java.lang.IllegalArgumentException: Missing {{ from the text: {"query":{"match_all":{}}}
        
      • Scenario 2
        query: '{{myQuery}}'

        Gives

        java.lang.IllegalArgumentException: Missing {{ from the text: {"query":{"match_all":{}}}
        
      • Scenario 3
        query: '#property:myQuery'

        Gives

        java.lang.IllegalArgumentException: Property with key myQuery not found by properties component
        

        But using debug I've checked that the above exception occurs due to the same

        java.lang.IllegalArgumentException: Missing {{ from the text: {"query":{"match_all":{}}}
        
      • Scenario 4
        I've also tried to change the Kamelet YAML definition to use the RAW value directly
        - set-body: 
          constant: "RAW({{myQuery}})"

        With the same result

        java.lang.IllegalArgumentException: Missing {{ from the text: {"query":{"match_all":{}}}
        

      I have a workaround if I add spaces in JSON like below it works in scenarios 1 and 2.

      { "query": { "match_all": { } } } 

      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:

      query: '{{raw:myQuery}}'

      Or with a default value

      query: '{{raw:myQuery:{"query":{"match_all":{}}}}}'

      Or at least have a way to escape curly brackets.

      Attachments

        Issue Links

          Activity

            People

              davsclaus Claus Ibsen
              MarcoMartins Marco Martins
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: