How to fix Callable Functions: INVALID_ARGUMENT - Request malformed in Firebase

FirebaseBEGINNERMEDIUMUpdated Dec 22, 2025ยท 126 views

This error occurs when the request payload to a Firebase Callable Function is incorrectly formatted. The issue typically stems from extra fields in the request body, missing the required "data" field, or sending non-JSON-serializable data.

Quick fix

Fixes Callable Functions: INVALID_ARGUMENT - Request malformed

// Correct - using Firebase SDK
import { getFunctions, httpsCallable } from 'firebase/functions';

const functions = getFunctions();
const myFunction = httpsCallable(functions, 'myFunctionName');

// Call with data wrapped automatically
const result = await myFunction({ userId: '123', action: 'update' });
  1. Verify you are using the Firebase SDK correctly
  2. Check for non-serializable data types
  3. Pass data as a single parameter object
  4. Update Firebase SDK to the latest version
firebase โ€” error
// Correct - using Firebase SDK
import { getFunctions, httpsCallable } from 'firebase/functions';
const functions = getFunctions();
const myFunction = httpsCallable(functions, 'myFunctionName');
// Call with data wrapped automatically
const result = await myFunction({ userId: '123', action: 'update' });
Callable Functions: INVALID_ARGUMENT - Request malformed

What this error means

The INVALID_ARGUMENT error in Firebase Callable Functions indicates that the HTTP request sent to your cloud function does not conform to the expected protocol. Firebase callable functions have strict requirements for the request structure - the request body must be a valid JSON object containing a "data" field with your function arguments. When Firebase receives a request that violates these requirements, it immediately rejects the call before your function code even executes. This is a client-side validation error that prevents malformed or potentially harmful requests from reaching your backend logic. The error is part of Firebase's standardized error codes (functions/invalid-argument) used across all client SDKs. Common violations include sending extra fields alongside "data", omitting the "data" field entirely, sending non-JSON payloads, or including data types that cannot be serialized to JSON. The Firebase protocol specification requires that only the "data" field be present in the request body, containing any valid JSON value (primitives, objects, or arrays).

Typical symptoms

  • Function calls fail immediately with INVALID_ARGUMENT error code
  • Error occurs before function execution logs appear in Firebase Console
  • Same error happens consistently across different environments
  • Client SDK throws "functions/invalid-argument" exception
  • Request works with simple data but fails with complex objects

Common causes

  1. Request body contains extra fields beyond the required "data" field
  2. Missing the "data" field in the request payload entirely
  3. Passing non-JSON-serializable data types (functions, symbols, circular references)
  4. Manually constructing HTTP requests without proper Firebase protocol format
  5. Client SDK version mismatch causing incorrect request formatting
  6. Sending undefined or null as the entire payload instead of wrapping in data object

How to fix "Callable Functions: INVALID_ARGUMENT - Request malformed"

1Verify you are using the Firebase SDK correctly

Ensure you are calling the function through the official Firebase SDK, not raw HTTP requests. The SDK handles proper request formatting automatically.

javascript
// Correct - using Firebase SDK
import { getFunctions, httpsCallable } from 'firebase/functions';

const functions = getFunctions();
const myFunction = httpsCallable(functions, 'myFunctionName');

// Call with data wrapped automatically
const result = await myFunction({ userId: '123', action: 'update' });
javascript
// Incorrect - manual HTTP request (common mistake)
fetch('https://us-central1-myproject.cloudfunctions.net/myFunction', {
  method: 'POST',
  body: JSON.stringify({ userId: '123' }) // Missing proper Firebase protocol
});

The Firebase SDK automatically wraps your data in the correct protocol format.

2Check for non-serializable data types

Ensure all data passed to the callable function can be serialized to JSON. Remove functions, symbols, undefined values, and circular references.

javascript
// Incorrect - contains non-serializable data
const badData = {
  name: 'John',
  callback: function() { }, // Functions cannot be serialized
  symbol: Symbol('test'),   // Symbols cannot be serialized
  date: new Date()          // Dates serialize to strings, may cause issues
};

await myFunction(badData); // Will fail
javascript
// Correct - only JSON-serializable data
const goodData = {
  name: 'John',
  timestamp: Date.now(), // Use timestamp instead of Date object
  userId: '123',
  metadata: { key: 'value' }
};

await myFunction(goodData); // Will succeed

Convert dates to timestamps or ISO strings, and remove any function references.

3Pass data as a single parameter object

Firebase callable functions expect a single data parameter. If you need to pass multiple values, wrap them in a single object.

javascript
// Incorrect - passing multiple arguments
await myFunction('userId', 'action', 'value'); // Not supported
javascript
// Correct - single object parameter
await myFunction({
  userId: 'userId',
  action: 'action',
  value: 'value'
}); // Properly formatted

Even when passing a single primitive value, it's best practice to wrap it in an object for clarity and future extensibility.

4Update Firebase SDK to the latest version

Outdated SDK versions may have bugs in request formatting. Update to the latest Firebase SDK version.

bash
# For npm
npm update firebase

# For specific version
npm install firebase@latest

# Check installed version
npm list firebase

After updating, clear your build cache and restart your development server to ensure the new version is being used.

5Validate your function server-side implementation

Ensure your cloud function is correctly defined as a callable function using https.onCall, not a regular HTTP function.

javascript
// Correct - callable function definition
import { onCall } from 'firebase-functions/v2/https';

export const myFunction = onCall((request) => {
  const data = request.data; // Data automatically extracted
  const userId = data.userId;

  // Your function logic here
  return { success: true, message: 'Done' };
});
javascript
// Incorrect - regular HTTP function (different protocol)
import { onRequest } from 'firebase-functions/v2/https';

export const myFunction = onRequest((req, res) => {
  // This expects different request format
  res.json({ success: true });
});

Callable functions use a different protocol than regular HTTP functions and require the onCall handler.

Advanced notes

Protocol Details: Firebase callable functions use a specific JSON-RPC-like protocol. The request body must be a JSON object with a single "data" field. Any additional fields (even metadata) will cause the request to be rejected. The response format is similarly strict, requiring a "result" field for successful responses or an "error" field for failures.

CORS Handling: Unlike regular HTTP Cloud Functions, callable functions automatically handle CORS preflight requests. If you are manually setting CORS headers or using middleware, it may interfere with the callable function protocol. Remove custom CORS handling when using callable functions.

Authentication Context: Callable functions automatically verify Firebase Authentication tokens and populate the request.auth context. Do not manually parse or validate auth tokens - use the provided request.auth object which contains the verified user information.

Request Size Limits: Firebase callable functions have a 10MB request size limit. If you're sending large amounts of data, consider using Cloud Storage for file uploads and passing only references to the callable function. Exceeding size limits may result in malformed request errors.

Local Emulator: When testing with the Firebase Local Emulator Suite, ensure you are connecting to the emulator correctly. The client SDK needs to be configured to point to localhost:5001 (or your custom emulator port) using connectFunctionsEmulator(). Incorrect emulator configuration can cause protocol mismatches.

Frequently asked questions

What does "Callable Functions: INVALID_ARGUMENT - Request malformed" mean?
The INVALID_ARGUMENT error in Firebase Callable Functions indicates that the HTTP request sent to your cloud function does not conform to the expected protocol. Firebase callable functions have strict requirements for the request structure - the request body must be a valid JSON object containing a "data" field with your function arguments. When Firebase receives a request that violates these requirements, it immediately rejects the call before your function code even executes.
How do I fix "Callable Functions: INVALID_ARGUMENT - Request malformed"?
This error occurs when the request payload to a Firebase Callable Function is incorrectly formatted. The issue typically stems from extra fields in the request body, missing the required "data" field, or sending non-JSON-serializable data.
What causes "Callable Functions: INVALID_ARGUMENT - Request malformed"?
Request body contains extra fields beyond the required "data" field Missing the "data" field in the request payload entirely Passing non-JSON-serializable data types (functions, symbols, circular references)
Is the "Callable Functions: INVALID_ARGUMENT - Request malformed" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading