Open nxfi777 opened 4 months ago
Using the query() method, occasionally I will get a URL component 'query' too long error (httpx module)
query()
URL component 'query' too long
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
MAX_URL_LENGTH = 65536
I know with certainty that the URL length (from my inputs) do not exceed 65535 characters.
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:
SurrealHTTP
axios
let config = { headers: { 'Accept': 'application/json' }, params: bindings, // bind variables in the request params maxContentLength: Infinity, maxBodyLength: Infinity, };
The query should execute correctly, without issues.
1.1.1+20240116.b261047
surrealdb.py 0.3.1 for windows running Python 3.12.1
nafironato@pm.me
Hey @nxfi777 from what I understand you want there to be no limit on the URL?
Yes
Describe the bug
Using the
query()
method, occasionally I will get aURL component 'query' too long
error (httpx module)Traceback
Relevant httpx code:
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:With my own node.js
SurrealHTTP
class, I've managed to mitigate any errors like this with theseaxios
parameters: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?
Code of Conduct