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.
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).
Ensure you are calling the function through the official Firebase SDK, not raw HTTP requests. The SDK handles proper request formatting automatically.
// 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' });// 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.
Ensure all data passed to the callable function can be serialized to JSON. Remove functions, symbols, undefined values, and circular references.
// 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// 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 succeedConvert dates to timestamps or ISO strings, and remove any function references.
Firebase callable functions expect a single data parameter. If you need to pass multiple values, wrap them in a single object.
// Incorrect - passing multiple arguments
await myFunction('userId', 'action', 'value'); // Not supported// Correct - single object parameter
await myFunction({
userId: 'userId',
action: 'action',
value: 'value'
}); // Properly formattedEven when passing a single primitive value, it's best practice to wrap it in an object for clarity and future extensibility.
Outdated SDK versions may have bugs in request formatting. Update to the latest Firebase SDK version.
# For npm
npm update firebase
# For specific version
npm install firebase@latest
# Check installed version
npm list firebaseAfter updating, clear your build cache and restart your development server to ensure the new version is being used.
Ensure your cloud function is correctly defined as a callable function using https.onCall, not a regular HTTP function.
// 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' };
});// 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.
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.
messaging/UNSPECIFIED_ERROR: No additional information available
How to fix "messaging/UNSPECIFIED_ERROR: No additional information available" in Firebase Cloud Messaging
App Check: reCAPTCHA Score Too Low
App Check reCAPTCHA Score Too Low
storage/invalid-url: Invalid URL format for Cloud Storage reference
How to fix invalid URL format in Firebase Cloud Storage
auth/missing-uid: User ID identifier required
How to fix "auth/missing-uid: User ID identifier required" in Firebase
auth/invalid-argument: Invalid parameter passed to method
How to fix "auth/invalid-argument: Invalid parameter passed to method" in Firebase