Fix query id extraction from request query#265
Conversation
| public static final String HOST_HEADER = "Host"; | ||
| private static final int QUERY_TEXT_LENGTH_FOR_HISTORY = 200; | ||
| private static final Pattern QUERY_ID_PATTERN = Pattern.compile(".*[/=?](\\d+_\\d+_\\d+_\\w+).*"); | ||
| private static final Pattern QUERY_ID_PARAM_PATTERN = Pattern.compile(".*(?:%2F|=|^)(\\d+_\\d+_\\d+_\\w+).*"); |
There was a problem hiding this comment.
I am curious if trino also uses the same pattern.
There was a problem hiding this comment.
Trino uses a lightweight test that only checks for characters in the set [_a-z0-9]. A queryId could technically be something like "testqueryid", as you see in some tests, but the generator imposes a specific format
These patterns impose additional restrictions on where a queryid can appear to reduce false positives.
vishalya
left a comment
There was a problem hiding this comment.
Overall looks good, apart from minor comments.
2bc7f9f to
24d9c17
Compare
e7d8f53 to
c89ea0d
Compare
| private static final int QUERY_TEXT_LENGTH_FOR_HISTORY = 200; | ||
| private static final Pattern QUERY_ID_PATTERN = Pattern.compile(".*[/=?](\\d+_\\d+_\\d+_\\w+).*"); | ||
| private static final Pattern QUERY_ID_PATH_PATTERN = Pattern.compile(".*/(\\d+_\\d+_\\d+_\\w+).*"); | ||
| private static final Pattern QUERY_ID_PARAM_PATTERN = Pattern.compile(".*(?:%2F|(?i)query_?id(?-i)=|^)(\\d+_\\d+_\\d+_\\w+).*"); |
There was a problem hiding this comment.
oh how I hate regex like this .. should we somehow add some Java doc that explains it a little bit .. or do we just treat the test as the docs?
mosabua
left a comment
There was a problem hiding this comment.
Looks good even if the regex is really not easily readable. Feel free to add some javadoc if you think it helps .. but otherwise also feel free to ship as it is now
c89ea0d to
5a6bbad
Compare
|
@Chaho12 also confirmed in the dev sync on the 6th of March that this PR is good to go. |
mosabua
left a comment
There was a problem hiding this comment.
Thanks for adding the comments.
The logic for extracting a query id from the request query was broken. The test for this functionality was also broken, since it passed the
queryto the extraction method as part of thepath.