-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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]: Semicolons break fulltext search #8787
Comments
Hi @lithdoh, would it be possible for you to provide the GraphQL schema that you are using? That would help us easily reproduce this issue and hopefully fix it too. |
Hi Aman, I have updated the github bug issue with my schema. I have
recently discovered that the backslash character "\" has the same result as
searching with semicolons.
…On Fri, Apr 7, 2023 at 4:09 AM Aman Mangal ***@***.***> wrote:
Hi @lithdoh <https://github.com/lithdoh>, would it be possible for you to
provide the GraphQL schema that you are using? That would help us easily
reproduce this issue and hopefully fix it too.
—
Reply to this email directly, view it on GitHub
<#8787 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AYAT3Z4XX2JH5GIGL7PR2WDW77YVRANCNFSM6AAAAAAWTLLQRE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Everything seems to work for me. I tried the following:
I get the following response:
|
Maybe, if you could share the exact steps that you are following, or try the steps that I mentioned here and see whether these steps work for you. Thank you |
@mangalaman93 Thanks for your reply. I followed the steps you mentioned exactly and got the same result that you did:
But immediately after when I tried a similar query like this: http://localhost:8080/graphql?query= I got the error:
Note: Your example escapes the quotations around the search terms: I verified that if I try the same query with no semicolons: http://localhost:8080/graphql?query= I get the correct result of an empty array:
|
Could you give me exact curl commands that you ran? |
I just copied and pasted the ones you provided.
Run query:
Is there some reason why making the query using the endpoint "http://localhost:8080/graphql?query=" would yield different results? |
I am thinking that this could have something to do with bash. The shell usually interprets the |
If you ran the following on bash, this clearly won't work:
|
It looks like you are using the back quote (`) instead of the single quote
(‘).
…On Tue, Apr 18, 2023 at 4:42 AM Aman Mangal ***@***.***> wrote:
If you ran the following on bash, this clearly won't work:
http://localhost:8080/graphql?query=
`{ queryStems(filter: {name: {alloftext: "text;with;semicolons"}}) { id name price } }`
—
Reply to this email directly, view it on GitHub
<#8787 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAH3WHB2KHV4RPPEIIMNCSDXBZ43HANCNFSM6AAAAAAWTLLQRE>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
The backticks were because I used the code formatter in the Github editor
when I was writing the reply. Now I am replying by email. So the request
URL is
http://localhost:8080/graphql?query={ queryStems(filter: {name:
{alloftext: "text;with;semicolons"}}) { id name price } }
This is not something that you copy and paste in Bash, you would paste this
in your browser's address bar.
…On Tue, Apr 18, 2023 at 4:45 AM Akon Dey ***@***.***> wrote:
It looks like you are using the back quote (`) instead of the single quote
(‘).
On Tue, Apr 18, 2023 at 4:42 AM Aman Mangal ***@***.***>
wrote:
> If you ran the following on bash, this clearly won't work:
>
> http://localhost:8080/graphql?query=
> `{ queryStems(filter: {name: {alloftext: "text;with;semicolons"}}) { id
name price } }`
>
> —
> Reply to this email directly, view it on GitHub
> <#8787 (comment)
>,
> or unsubscribe
> <
https://github.com/notifications/unsubscribe-auth/AAH3WHB2KHV4RPPEIIMNCSDXBZ43HANCNFSM6AAAAAAWTLLQRE
>
> .
> You are receiving this because you are subscribed to this thread.Message
> ID: ***@***.***>
>
—
Reply to this email directly, view it on GitHub
<#8787 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AYAT3Z2EKA6G7AGM27MDGM3XBZ5HPANCNFSM6AAAAAAWTLLQRE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
yeah, I now realize that you are doing it from the browser. The issue is related to this golang/go#25192. |
I am not sure how it would work in the browser because the query part of the URL (everything after the ?) is not allowed to have a |
But isn't it a common thing to use an HTTP client with a request URL programmatically and not in the browser? Like an http get request with a URL like we are talking about? |
Could you help us understand your use case a bit more? Why do you want to use semicolons in the function arguments? |
It's because I have a search input that filters by Stem names and if a semicolon or back slash "\" is entered I get the error. I don't want to have to implement a filter on the input to remove these characters. I don't feel that it should throw an error if someone tries to filter Stems with any string containing those characters. |
Will it be possible for you to share the javascript code that does this? I am thinking it should be possible to send the |
I'm using Angular, here is the code:
|
We found more documentation from the Go stdlib docs https://go.dev/doc/go1.17#semicolons |
One thing that could help here is to URL encode the parameters. Though, I think what you are doing could lead to GraphQL injection and instead you should send the query and the variable in the body. I am not familiar with angular but if you can't figure it out, I can look into it. There should be a way to send the query and the variable in the request body. You can look at the reference here https://dgraph.io/docs/graphql/graphql-clients/endpoint/ |
The URL after encoding parameters look like this http://localhost:8080/graphql?query={%20queryStems(filter:%20{name:{alloftext:%20%22text%3Bwith%3Bsemicolons%22}})%20{%20id%20name%20price%20}%20} and it works for me. Though, we discourage the use of the GET request because a URL cannot be longer than 2048 chars as well this could lead to GraphQL injection. Instead, one should use the POST request to hit the /graphql endpoint as explained here https://dgraph.io/docs/graphql/graphql-clients/endpoint/graphql-request/ |
Wow thanks! That is very helpful. I will research that now. |
What version of Dgraph are you using?
dgraph/standalone:latest
Schema:
Have you tried reproducing the issue with the latest release?
Yes
What is the hardware spec (RAM, CPU, OS)?
Irrelevant
What steps will reproduce the bug?
Make any query that uses fulltext search "alloftext" or "anyoftext" that contains one or more semicolons or backslashes.
Expected behavior and actual result.
When I enter any string containing a semicolon or backslash in the fulltext search, I get the error
“no query string supplied in request”
This is a sample GraphQL query that produces the error
The issue does not occur when the same query is used in the Dgraph Cloud Explorer for some reason.
I’m using the Docker dgraph/standalone:latest image.
Additional information
The full error message was:
{"errors":[{"message":"no query string supplied in request"}],"extensions":{"tracing":{"version":1,"startTime":"2023-04-04T23:41:00.55157713Z","endTime":"2023-04-04T23:41:00.551966171Z","duration":389041}}}
The text was updated successfully, but these errors were encountered: