Skip to content

fix(call): prevent callFunction crash when request body is missing#139

Open
codxbrexx wants to merge 1 commit intometacall:masterfrom
codxbrexx:fix/callfunction-req-body
Open

fix(call): prevent callFunction crash when request body is missing#139
codxbrexx wants to merge 1 commit intometacall:masterfrom
codxbrexx:fix/callfunction-req-body

Conversation

@codxbrexx
Copy link
Copy Markdown
Contributor

Summary

This PR fixes by hardening callFunction against missing or invalid request bodies.

Previously, the route could synchronously throw when req.body was undefined or null, because Object.values(req.body) was evaluated without a guard. This commonly affects GET requests and requests where Express does not populate the body.

The fix safely extracts arguments only when req.body is an object:

image

This preserves normal invocation behavior for object payloads while avoiding crashes for empty, null, or primitive bodies.

Problem statement

callFunction is exposed through both GET and POST routes. In normal GET requests, or in requests where Express does not parse a body, req.body can be undefined.

The previous implementation effectively relied on:

Object.values(req.body)

That throws TypeError: Cannot convert undefined or null to object when req.body is missing, so the route fails before the function invocation is sent to the worker.

Related issue

  • Testing Requirement: added focused controller tests covering undefined, null, object, and primitive request bodies

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Chore / CI
  • Breaking change

How to test

  1. Checkout the branch with this change.
  2. Run cd faas && npm test.
  3. Verify the Fix: callFunction Request Body Handling suite passes.
  4. Optionally call the route without a body and confirm it no longer crashes before dispatching the invocation.

Checklist

  • I have read the contributing guidelines
  • I added tests that prove my fix is effective or that my feature works
  • I updated documentation if necessary

Release notes

Fixed callFunction so requests without a parsed body no longer crash the FaaS route.

Prevent callFunction from throwing when req.body is undefined or null.
Also adds focused controller tests covering empty, object, and primitive
request body inputs for Issue .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant