Ibaraki DoujiOriginal post
Rank 3: Container
So i wanted to run a function, tho i don't have any body on this one, and when executing, i got an error 500.
Code:
JavaScript
const client = new AppwriteClient() .setEndpoint(process.env.APPWRITE_FUNCTION_API_ENDPOINT) .setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID) const functions = new Functions(client); const f = await functions.createExecution("67d8394c0038d8f14c00", null, false);SDK Error:
AppwriteException: Server Error
at _Client.call (file://<file>)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async handler (file://<file>) {
code: 500,
type: 'general_unknown',
response: '{"message":"Server Error","code":500,"type":"general_unknown","version":"1.6.1"}'
}
API/Server Error:
2025-03-17T16:46:20.244116082Z [Error] Timestamp: 2025-03-17T16:46:20+00:00
2025-03-17T16:46:20.244211771Z [Error] Method: POST
2025-03-17T16:46:20.244232189Z [Error] URL: /v1/functions/:functionId/executions
2025-03-17T16:46:20.244237238Z [Error] Type: TypeError
2025-03-17T16:46:20.244242228Z [Error] Message: {closure}(): Argument #2 ($body) must be of type string, null given, called in /usr/src/code/vendor/utopia-php/framework/src/App.php on line 607
2025-03-17T16:46:20.244247346Z [Error] File: /usr/src/code/app/controllers/api/functions.php
2025-03-17T16:46:20.244252145Z [Error] Line: 1768
After a look, i changed the body from null to "" and it worked, tho i think there is some missing checks (convert null body to something, prevent null in the SDK, better SDK error description)
Summary
Error 500 occurred when executing a function without a body in the code. Changing the body from `null` to `""` resolved the issue. Developers suggested implementing better checks to handle null bodies in the SDK and improving the error descriptions.