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:
TypeScript
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:
TypeScript
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:
TypeScript
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)
TL;DR
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.Recommended threads
- [Self-hosted] Realtime crashes with "Mis...
- Error trying to deploy functions from CL...
✗ Error • on-auth-create (6a00b2ab000c9ce2949b) • Server Error ✗ Error: No functions were pushed. Prject ID: 69ffe0270033a4ac420a
- Intermittent Deploy and Execution Errors...
Project: project-fra-658e2f5f4ba30df91177 Function ID: 69bde006001c56757f49 **Several execution errors with:** Timed out waiting for runtime.\nError Code: 400...