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

Bug: SurrealHTTP URL query length #87

Open
2 tasks done
nxfi777 opened this issue Feb 7, 2024 · 2 comments
Open
2 tasks done

Bug: SurrealHTTP URL query length #87

nxfi777 opened this issue Feb 7, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@nxfi777
Copy link

nxfi777 commented Feb 7, 2024

Describe the bug

Using the query() method, occasionally I will get a URL component 'query' too long error (httpx module)

Traceback


2024-02-06 19:15:44,231 ERROR:Traceback: Traceback (most recent call last):

await db.query(f"UPDATE example:example SET input=type::string($i),output=type::string($o)")

File "/usr/local/lib/python3.12/site-packages/surrealdb/http.py", line 188, in query

response = await self._request(method="POST", uri="/sql", data=sql, params=vars)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/local/lib/python3.12/site-packages/surrealdb/http.py", line 119, in _request

surreal_response = await self._http.request(

^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1546, in request

request = self.build_request(

^^^^^^^^^^^^^^^^^^^

File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 359, in build_request

return Request(

^^^^^^^^

File "/usr/local/lib/python3.12/site-packages/httpx/_models.py", line 329, in __init__

self.url = self.url.copy_merge_params(params=params)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/local/lib/python3.12/site-packages/httpx/_urls.py", line 366, in copy_merge_params

return self.copy_with(params=self.params.merge(params))

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/local/lib/python3.12/site-packages/httpx/_urls.py", line 354, in copy_with

return URL(self, **kwargs)

^^^^^^^^^^^^^^^^^^^

File "/usr/local/lib/python3.12/site-packages/httpx/_urls.py", line 117, in __init__

self._uri_reference = url._uri_reference.copy_with(**kwargs)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/local/lib/python3.12/site-packages/httpx/_urlparse.py", line 134, in copy_with

return urlparse("", **defaults)

^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/local/lib/python3.12/site-packages/httpx/_urlparse.py", line 200, in urlparse

raise InvalidURL(f"URL component '{key}' too long")

httpx.InvalidURL: URL component 'query' too long

Relevant httpx code:

for key, value in kwargs.items():
       if value is not None:
           if len(value) > MAX_URL_LENGTH:
               raise InvalidURL(f"URL component '{key}' too long")

Where MAX_URL_LENGTH = 65536

I know with certainty that the URL length (from my inputs) do not exceed 65535 characters.

Steps to reproduce

Use the query() method and input a long string via the config, for example:

await db.query("CREATE code SET input=type::string($i),output=type::string($o)", {
    "i":"some input code",
    "o":"stdout"})

With my own node.js SurrealHTTP class, I've managed to mitigate any errors like this with these axios parameters:

let config = {
            headers: {
                'Accept': 'application/json'
            },
            params: bindings,   // bind variables in the request params
            maxContentLength: Infinity,
            maxBodyLength: Infinity,
        };

Expected behaviour

The query should execute correctly, without issues.

SurrealDB version

1.1.1+20240116.b261047

surrealdb.py version

surrealdb.py 0.3.1 for windows running Python 3.12.1

Contact Details

nafironato@pm.me

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct
@nxfi777 nxfi777 added the bug Something isn't working label Feb 7, 2024
@maxwellflitton
Copy link
Contributor

Hey @nxfi777 from what I understand you want there to be no limit on the URL?

@nxfi777
Copy link
Author

nxfi777 commented Jun 14, 2024

Hey @nxfi777 from what I understand you want there to be no limit on the URL?

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants