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

unable to set service_request_headers or service_request_body #18

Open
teb510 opened this issue Aug 16, 2024 · 2 comments
Open

unable to set service_request_headers or service_request_body #18

teb510 opened this issue Aug 16, 2024 · 2 comments

Comments

@teb510
Copy link

teb510 commented Aug 16, 2024

using the config below which the debug output shows as completing - i am unable to see the headers or body on the request sent to the upstream

_format_version: "1.1"

services:
- name: demo
  url: http://httpbin.org
  routes:
  - name: my-route
    paths:
    - /anything
    strip_path: false
    filter_chains:
    - filters:
      - name: datakit
        config:
          debug: true
          nodes:
          - name: FIRST
            type: call
            url: https://api.zippopotam.us/us/33162
          - inputs:
            - FIRST
            - request_headers
            name: JOIN
            output: RESP
            template: |
              {
                 "my_name": "{{ FIRST.country }}"
              }
            type: template
          - inputs:
            - FIRST
            name: MY_HEADERS
            output: service_request_headers
            template: |
              {
                "Content-Type": "application/json",
                "X-Hello": "World",
                "X-Foo": "Bar",
                "X-Name": "{{ FIRST.country }}"
              }
            type: template
          - inputs:
            - FIRST
            name: MY_BODY
            output: service_request_body
            template: |
              {
                "derp": "{{ FIRST.country }}"
              }
            type: template

relevant debug:

{
    "action": "run",
    "name": "MY_HEADERS",
    "type": "template"
  },
  {
    "action": "value",
    "name": "MY_HEADERS",
    "type": "application/json",
    "value": {
      "Content-Type": "application/json",
      "X-Foo": "Bar",
      "X-Hello": "World",
      "X-Name": "United States"
    }
  },
  {
    "action": "run",
    "name": "MY_BODY",
    "type": "template"
  },
  {
    "action": "value",
    "name": "MY_BODY",
    "type": "application/json",
    "value": {
      "derp": "United States"
    }
  },
  {
    "action": "value",
    "name": "response_body",
    "type": "application/json",
    "value": {
      "headers": {
        "Accept": "*/*",
        "Host": "httpbin.org",
        "User-Agent": "curl/8.7.1",
        "X-Amzn-Trace-Id": "Root=1-66bf807b-61f5b1bd11164c951588b014",
        "X-Datakit-Debug-Trace": "1",
        "X-Forwarded-Host": "localhost",
        "X-Forwarded-Path": "/headers",
        "X-Kong-Request-Id": "352aa93b0711886cf8b0d626d285336f"
      }
    }
  }
@hishamhm
Copy link
Collaborator

hishamhm commented Aug 19, 2024

@teb510 This particular case should be fixed in 0.1.1. If you could verify it, happy to close this one.

But I believe there might still be some limitations with service_request_body specifically that I still need to pin down.

I need to map/document the limitations properly, and I'm not sure if the root cause is with datakit, proxy-wasm, WasmX or Nginx. I think this is a more general matter than this particular issue; we need a comprehensive documentation on which combinations of operations work and which don't. (There are some things we can't do, especially when dealing the response, because of the streaming nature of the service response handling (a.k.a. "body_filter" in OpenResty lingo).)

@teb510
Copy link
Author

teb510 commented Aug 19, 2024

hey @hishamhm yes i can validate i was able to set service_request_headers but still cannot set the body.

i'm sure you already know this but the body is important to some of the use cases i went over with the field.

and yes totally agree - what is possible when will become a hot topic!

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