firebase / firebase/firebase-functions-test

firebase-functions-test@3.4.1 misdetects v2 callables

Open
#310 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
248
Forks
63
PR merge metrics
No merged PRs in 30d

Description

## Bug: firebase-functions-test@3.4.1 misdetects v2 callables when used with firebase-functions@7.x

### Environment
- firebase-functions: 7.x
- firebase-functions-test: 3.4.1
- Node: 22

### What happens is V2CloudFunction() detection fails silently.

The check:

cloudFunction.run.length === 1

returns false because firebase-functions@7.x wraps handlers
in rest-param functions:

async (...args) => { ... } // .length === 0, not 1

This causes wrap() to fall back to wrapV1, which calls:

handler.run(data, context) // two args — wrong for v2

Instead of the correct v2 invocation:

handler.run(req) // single CallableRequest object

### Impact
Tests using wrap() on v2 callable functions silently use
the wrong invocation path. Auth context is passed incorrectly,
causing permission-denied errors that are unrelated to actual
authorization logic.

### Workaround
Bypass wrap() entirely and call handler.run({ data, auth })
directly — which is what wrapV2 does internally.

### Steps to reproduce
1. Create a v2 callable using onCall() from firebase-functions@7.x
2. Wrap it with firebase-functions-test@3.4.1's wrap()
3. Invoke it with an auth context
4. Observe incorrect behavior / permission-denied errors

### Expected behavior
wrap() should correctly identify v2 callables and use the
single-argument invocation path regardless of the internal
wrapping firebase-functions uses.

---

I was able to successfully deploy after creating the workaround.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.