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

Elasticsearch: Fix resource calls for paths that include : #82327

Merged
merged 4 commits into from Feb 13, 2024

Conversation

ivanahuckova
Copy link
Member

@ivanahuckova ivanahuckova commented Feb 12, 2024

This PR follows up on #79746 and removes redundant logic that was using url.Parse to parse req.Path. Consequently, it also fixes the issue #79745 where url.Parse throws error when parsing path with :. Moreover it adds tests and does a small refactor to make testing of these (and future) changes easier.

To test, do a sanity check that resource calls work:

See field options:
image

Adhoc filters working:
image

Test data source working:
image

Fixes: #82327

}

// We take the path and the query-string only
esUrl.RawQuery = resourcePath.RawQuery
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, are we sure we never need or want to support query parameters in resources calls? Because I think some APIs in ES use GET query parameters, so I think we should also add this to createElasticsearchURL. WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resource path should not have any RawQuery based on following check req.Path != "" && !strings.HasSuffix(req.Path, "/_mapping") && req.Path != "_msearch" && req.Path != "_mapping". So it is not needed as there are currently no queries supported. Maybe I can add a comment explaining it - so when someone allows additional path/resource calls, they are aware of needing to implement raw query.

I also noticed that I haven't add test for why we are doing it - so I will also add test for path with : to ensure that it is covered.

But to summarise we can't use url.Parse(req.Path) anymore as it throws error for path that includes : , so I am worried, that if we wanted to go 1 step ahead and implement raw queries (even if it is not needed), we might introduce some issue related to splitting on ?. Or do you have any other ideas.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@svennergr svennergr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ivanahuckova ivanahuckova merged commit 082f020 into main Feb 13, 2024
12 checks passed
@ivanahuckova ivanahuckova deleted the ivana/es-cluser-fix branch February 13, 2024 12:44
Ukochka pushed a commit that referenced this pull request Feb 14, 2024
* Elasticsearch: Fix resource calls for paths that include :

* Add tests

* Add test case and comment

* Remove redundant comment
@aangelisc aangelisc modified the milestones: 10.4.x, 10.4.0 Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants