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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Bug Report: [Functions] Function Fails Without Logs If No Body is Provided #6431

Open
2 tasks done
ItzNotABug opened this issue Oct 2, 2023 · 4 comments
Open
2 tasks done
Assignees
Labels
bug Something isn't working product / functions Fixes and upgrades for the Appwrite Functions.

Comments

@ItzNotABug
Copy link
Contributor

ItzNotABug commented Oct 2, 2023

馃憻 Reproduction steps

  1. Execute a Function from the Dashboard
  2. Enter the Header as Content-Type: application/json
  3. Leave the Body empty.

Function's execution will fail with no logs, no errors.


Issue caused by -

if (contentType.includes('application/json')) {
    body = await parseJson(req);
}

Logs from container -

Error: Invalid JSON
08:36:01 0|server  |     at createError (/usr/local/server/node_modules/micro/lib/index.js:20:14)
08:36:01 0|server  |     at parseJSON (/usr/local/server/node_modules/micro/lib/index.js:120:9)
08:36:01 0|server  |     at /usr/local/server/node_modules/micro/lib/index.js:158:39
08:36:01 0|server  |     at processTicksAndRejections (node:internal/process/task_queues:96:5)
08:36:01 0|server  |     at async /usr/local/server/src/server.js:31:16

馃憤 Expected behavior

If the body doesn't exist, or empty then -

  1. Crash with an error
  2. Ignore & process the function as is

馃憥 Actual Behavior

Execution fails without any error.

馃幉 Appwrite version

Appwrite Cloud

馃捇 Operating system

Linux

馃П Your Environment

No response

馃憖 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

馃彚 Have you read the Code of Conduct?

@ItzNotABug ItzNotABug added the bug Something isn't working label Oct 2, 2023
@sundaram2021
Copy link

hey @ItzNotABug can you help me produce this error

@mc-stephen
Copy link

hey @ItzNotABug can you help me produce this error

Step to reproduce

  1. Create a sample node.js function
  2. upload the function to the appwrite console
  3. Run the function directly from the appwrite console
  4. While running the function don't pass in a body value, just leave it empty.
  5. Check the function log, and see it output.

Actual behaviour

Execution fails without any error.

Expected behaviour

Function should run but then only fail after note reading the json value for the json response, e.g (req.bodyRaw.value)

@stnguyen90 stnguyen90 added the product / functions Fixes and upgrades for the Appwrite Functions. label Oct 3, 2023
@stnguyen90
Copy link
Contributor

@ItzNotABug you said the actual behavior is:

Execution fails without any error.

What exactly shows in Appwrite for the execution (including the logs and errors)?

@stnguyen90 stnguyen90 self-assigned this Oct 3, 2023
@ItzNotABug
Copy link
Contributor Author

@stnguyen90 Nothing shows up in Logs or Errors tab, the status just shows failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working product / functions Fixes and upgrades for the Appwrite Functions.
Projects
None yet
Development

No branches or pull requests

5 participants