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
Conversation
} | ||
|
||
// We take the path and the query-string only | ||
esUrl.RawQuery = resourcePath.RawQuery |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR follows up on #79746 and removes redundant logic that was using
url.Parse
to parsereq.Path
. Consequently, it also fixes the issue #79745 whereurl.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:
Adhoc filters working:
Test data source working:
Fixes: #82327