Hey! i got a python function. it works locally. but whenever i try to run it on the server, i basically get this error:
TypeScript
appwrite.exception.AppwriteException: Invalid query: Syntax error```
TL;DR
Function is throwing a syntax error on the self-hosted server but runs fine locally. The issue seems to be in the query regarding the interpretation on the server. The error message indicates a syntax error in the query on the server. The logs show a 'Utopia\Database\Exception\Query' error. This could be due to how the query is handled server-side.TypeScript
File "/usr/local/server/src/function/runtime-env/lib/python3.9/site-packages/appwrite/client.py", line 114, in call
response.raise_for_status()
File "/usr/local/server/src/function/runtime-env/lib/python3.9/site-packages/requests/models.py", line 1024, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://appwrite.addix.campus/v1/databases/66b9be530000f859054e/collections/66b9becc002ef33bd228/documents?queries%5B0%5D=equal%28%22hasPDF%22%2C+false%29
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/server/src/server.py", line 163, in action
output = await asyncio.wait_for(execute(context), timeout=safeTimeout)
File "/usr/local/lib/python3.9/asyncio/tasks.py", line 479, in wait_for
return fut.result()
File "/usr/local/server/src/server.py", line 148, in execute
userModule = importlib.import_module("function." + userPath)
File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/usr/local/server/src/function/entrypoint.py", line 2, in <module>
from . import generatePDF
File "/usr/local/server/src/function/generatePDF.py", line 11, in <module>
result = getdata.getServicescheinewithoutPDF()
File "/usr/local/server/src/function/getdata.py", line 25, in getServicescheinewithoutPDF
result = databases.list_documents(
File "/usr/local/server/src/function/runtime-env/lib/python3.9/site-packages/appwrite/services/databases.py", line 916, in list_documents
return self.client.call('get', api_path, {
File "/usr/local/server/src/function/runtime-env/lib/python3.9/site-packages/appwrite/client.py", line 134, in call
raise AppwriteException(response.json()['message'], response.status_code, response.json().get('type'), response.json())
appwrite.exception.AppwriteException: Invalid query: Syntax error
no logs except in appwrite:
TypeScript
[Error] Timestamp: 2024-09-02T07:08:35+00:00
[Error] Method: GET
[Error] URL: /v1/databases/:databaseId/collections/:collectionId/documents
[Error] Type: Utopia\Database\Exception\Query
[Error] Message: Invalid query: Syntax error
[Error] File: /usr/src/code/vendor/utopia-php/database/src/Database/Query.php
[Error] Line: 225
i thiink it might have to do with how its interpreted? although i dont really see the error since it runs on my machine fine.
TypeScript
def getServicescheinewithoutPDF():
try:
query = 'equal("hasPDF", false)'
print(f"Query: {query}")
result = databases.list_documents(
database_id="66b9be530000f859054e",
collection_id="66b9becc002ef33bd228",
queries=[query]
)
print(f"Result: {result}")
return result
except Exception as e:
print(f"An error occurred: {e}")
raise```
this is the function i have
and hasPDF definitely exists...
Recommended threads
- Self-host migration from 1.8.X
Is it safe to now migrate from 1.7.4 to 1.8.X on my selfhost?
- DeploymentStatus enum value `canceled` m...
Hey, Sorry if it has been reported already, I found an issue using the Dart SDK where the `canceled` enum value is missing from `DeploymentStatus`. This causes...
- Synchronous function execution timeout w...
I am calling server functions with xasync = true and I still get this error message. Synchronous function execution timed out. Use asynchronous execution inste...