Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

http processors send body on GET #2527

Closed
mskarbek opened this issue Apr 17, 2024 · 3 comments
Closed

http processors send body on GET #2527

mskarbek opened this issue Apr 17, 2024 · 3 comments

Comments

@mskarbek
Copy link

mskarbek commented Apr 17, 2024

For:

pipeline:
  threads: -1
  processors:
    - branch:
        processors:
          - http:
              url: "https://REDACTED/service/rest/v1/components?repository=${! this.repo}"
              verb: GET
              headers:
                Accept: "application/json"
        result_map: "root.response = this"

I received 415 error from Sonatype Nexus server. Adding TRACE level of logging revealed that Benthos adds body to the request even if it is a GET which in turn upsets Nexus.
Is there a way to avoid sending body with GET requests?

@packman80
Copy link

packman80 commented Apr 18, 2024

From documentation:

A Bloblang mapping that describes how to create a request payload suitable for the child processors of this branch. If left empty then the branch will begin with an exact copy of the origin message (including metadata).

You need to get empty message without copy of original message. In this case you avoid sending body in GET request. Use it:

pipeline:
  threads: -1
  processors:
    - branch:
        request_map: root = "" 
        processors:
          - http:
              url: "https://REDACTED/service/rest/v1/components?repository=${! this.repo}"
              verb: GET
              headers:
                Accept: "application/json"
        result_map: "root.response = this"

@packman80
Copy link

it may be worth clarifying this in the documentation. In addition, the option to ignore sending the request body in the GET method might be useful, even if the message (and the request body, respectively) is not empty. In some cases, this would simplify the configs

@mihaitodor
Copy link
Collaborator

You don't necessarily need to use a branch processor. If you only wish to retain the response of the http processor, then placing a mapping processor before it with root = "" will suffice.

it may be worth clarifying this in the documentation.

From https://www.benthos.dev/docs/components/processors/http:

Performs an HTTP request using a message batch as the request body

The branch processor is a common utility which can be combined with any other processor, depending on the use case. Not sure how to help users discover it easier. It's definitely covered in the cookbooks, like for example this one: https://www.benthos.dev/cookbooks/enrichments

@redpanda-data redpanda-data locked and limited conversation to collaborators Apr 21, 2024
@mihaitodor mihaitodor converted this issue into discussion #2533 Apr 21, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants