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

multiple templates are referenceable as input for a response #22

Open
teb510 opened this issue Aug 19, 2024 · 1 comment
Open

multiple templates are referenceable as input for a response #22

teb510 opened this issue Aug 19, 2024 · 1 comment

Comments

@teb510
Copy link

teb510 commented Aug 19, 2024

in the below example - i create two templates and then use them both as inputs for the response. only the first template is used (confirmed this by swapping them around). i feel something should be explicit here - you cannot set multiple templates as inputs for the response. i think this should return an error.

_format_version: "1.1"

services:
- name: demo
  url: https://httpbin.org
  routes:
  - name: my-route
    paths:
    - /anything
    strip_path: false
    filter_chains:
    - filters:
      - name: datakit
        config:
          debug: true
          nodes:
          - name: CAT_FACT
            type: call
            url:  https://catfact.ninja/fact
          - name: CHUCK_NORRIS_FACT
            type: call
            url:  https://api.chucknorris.io/jokes/random
          - inputs:
            - CAT_FACT
            - CHUCK_NORRIS_FACT
            name: JOIN
            jq: |
              {
                 "cat_fact": $CAT_FACT.fact,
                 "chuck_norris_fact": $CHUCK_NORRIS_FACT.value
              }
            type: jq

          - inputs:
            - CAT_FACT
            - CHUCK_NORRIS_FACT
            name: JOINX2
            jq: |
              {
                 "wtf_will_happen": $CAT_FACT.fact,
                 "huh_wtf": $CHUCK_NORRIS_FACT.value
              }
            type: jq

          - inputs:
            - JOINX2
            - JOIN
            type: response 
            status: 200
@hishamhm
Copy link
Collaborator

i think this should return an error

Agreed, we're not validating on the numbers of inputs/outputs based on node type. Ideally, this should be done at the schema validation level, but I'm not sure if JSON Schema is smart enough for this. If it isn't, we'll have to validate at runtime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants