Skip to content

Relative URI path of Elasticsearch is removed from the base URI #7878

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

Closed
zsonglorman opened this issue Aug 8, 2023 · 3 comments · Fixed by #7883
Closed

Relative URI path of Elasticsearch is removed from the base URI #7878

zsonglorman opened this issue Aug 8, 2023 · 3 comments · Fixed by #7883
Labels
8.x Relates to a 8.x client version

Comments

@zsonglorman
Copy link

zsonglorman commented Aug 8, 2023

Elastic.Clients.Elasticsearch version: 8.9.0

Elasticsearch version: 8.8.1

.NET runtime version: 6.0

Operating system version: Windows 10

Description of the problem including expected versus actual behavior:
We have Elasticsearch hosted on a relative path, such as: https://mysite.com/elastic/
When we try to make any search request from the .NET client, we are getting 404 error because the client uses only the base uri: https://mysite.com/

Steps to reproduce:

  1. Set URI of elasticsearch: var uri = new Uri("https://mysite.com/elastic/");
  2. Initialize node pool: var nodePool = new SingleNodePool(uri);
  3. Initialize settings: var settings = new ElasticsearchClientSettings(nodePool, ...);
  4. Initialize client: var client = new ElasticsearchClient(settings);
  5. Make any request, e.g. var info = client.Info();
    In the response (via debug information enabled, and via OnRequestCompleted logging) we can see that the requested URL was: GET https://mysite.com/?pretty=true&error_trace=true (/elastic/ path is missing).

Expected behavior
We expect the .NET client not to alter the original elasticsearch URI path provided.

More info
In the old NEST Elastic .NET Client (e.g. v7.15.0) this bug doesn't occur. I found this connected issue, which deals with the very same bug we experience: #3691

I believe the bug is connected to Uri construction, see Microsoft documentation remarks here:

if the relativeUri begins with a slash, then it will replace any relative part of the baseUri

In the NEST v7 client, ApiUrlsLookups class contains all paths without leading slash (thus it won't replace the relative part of the base uri):

image

However, in the current v8 client, ApiUrlLookup class contains all paths with leading slash (thus it will replace the relative part of the base uri):

image

@zsonglorman zsonglorman added the 8.x Relates to a 8.x client version label Aug 8, 2023
@flobernd
Copy link
Member

flobernd commented Aug 8, 2023

Thanks for the detailed bug report! I'll have a look later today 🙂

@flobernd flobernd added the bug label Aug 8, 2023
@flobernd
Copy link
Member

flobernd commented Aug 8, 2023

I confirmed this bug is indeed caused by the leading / character. I'll implement a fix in the code generator and make sure it will be included in the next patch release.

@zsonglorman
Copy link
Author

Thanks a lot for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.x Relates to a 8.x client version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants