kestra-io / plugin-azure

Apache License 2.0
2 stars 5 forks source link

EventHub Produce from.body: "{{body}}" should be dynamic but it's not #128

Closed pavel-mxsf closed 2 weeks ago

pavel-mxsf commented 2 weeks ago

Expected Behavior

I'd like to call REST API and send result body to eventhub. Like this kafka blueprint: blueprint 151.

Actual Behaviour

It sends message to eventHub, but message body contains {{ outputs.api.body }} string instead of actual API response body.

Steps To Reproduce

See attached example (secrets and URLs redacted), log task shows what I expect in eventHub message.

Environment Information

Example flow

tasks:
  - id: api
    type: io.kestra.plugin.core.http.Request
    method: GET
    uri: http://xxx.com/xxx

  - id: logRequestDone
    type: io.kestra.plugin.core.log.Log
    message:
      - "{{ outputs.api.body }}"

  - id: testEventhub
    type: io.kestra.plugin.azure.eventhubs.Produce
    from:
      body: "{{ outputs.api.body }}"
    namespace: xxx
    eventHubName: xxx
    connectionString: "xxx"
    bodySerializer: JSON    
    bodyContentType: application/json
    eventProperties:
      source: kestra
anna-geller commented 2 weeks ago

can you try wrapping it in fromJson()?

id: repro
namespace: test
tasks:
  - id: api
    type: io.kestra.plugin.core.http.Request
    method: GET
    uri: https://reqres.in/api/repro

  - id: testEventhub
    type: io.kestra.plugin.azure.eventhubs.Produce
    disabled: true
    from:
      body: "{{ fromJson(outputs.api.body) }}"
    namespace: xxx
    eventHubName: xxx
    connectionString: "xxx"
    bodySerializer: JSON    
    bodyContentType: application/json
    eventProperties:
      source: kestra
pavel-mxsf commented 2 weeks ago

can you try wrapping it in fromJson()?

It doesn't do anything with that string, just sends "{{ fromJson(outputs.api.body) }}" to EH.