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

[BUG] Headers provided in the request are not respected in the RestClientTransport #1234

Open
bcallender opened this issue Oct 17, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@bcallender
Copy link

What is the bug?

If you create a Request with headers, then send the request via the RestClientTransport, those headers are ignored, and not included in the request that is actually sent to opensearch.

How can one reproduce the bug?

Create any request to any endpoint and specify a header

    Request request =
            Requests.builder()
                    .endpoint(endpoint)
                    .headers(List.of(Map.entry("osd-xsrf", "true")))
                    .method(RestRequest.Method.POST.name())
                    .json(objectMapper.writeValueAsString(patternPayload))
                    .build();

send that request via the OpensearchGenericClient's execute() function, with the transport configured to use the RestClientTransport.

You will find that the sent message does not include this header, making it impossible to do things like create index patterns programmatically using the dashboards API. The issue is in prepareLowLevelRequest(), which does not merge the headers from the incoming request object, only creating new ones. I'm not sure if the same behavior occurs with the other transport clients.

What is the expected behavior?

If I provide headers in my request, those headers should also appear in the request made to Opensearch and should not be lost.

What is your host/environment?

Mac OS 14.6 -- Running Opensearch 2.19.0 in Kubernetes, and using the latest version of the opensearch-java library (2.15.0)

Do you have any screenshots?

N/A

Do you have any additional context?

Add any other context about the problem.

@bcallender bcallender added bug Something isn't working untriaged labels Oct 17, 2024
@Xtansia Xtansia removed the untriaged label Oct 17, 2024
@Xtansia
Copy link
Collaborator

Xtansia commented Oct 17, 2024

Thank you for catching this @bcallender!
Would you be interested in contributing a fix for this?

@bcallender
Copy link
Author

I can take a look into this, sure. I'll need some time to get up to speed, would be my first contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants