Repository navigation
fix: route v2 callables through wrapV2 when platform is gcfv2 - #311
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for identifying and wrapping GCFv2 callable functions by checking the platform field in the endpoint metadata. Key changes include exporting the isCallableV2Function utility, updating the wrap function to prioritize v2 callable detection, and adding a corresponding test case in spec/main.spec.ts to ensure correct routing. There are no review comments to address, and I have no further feedback to provide.
cabljac
left a comment
There was a problem hiding this comment.
This looks great. The __endpoint.platform === 'gcfv2' check is a much more stable signal than counting function parameters, and the regression test covers the routing path nicely. A couple of small questions below, neither blocking.
cabljac
left a comment
There was a problem hiding this comment.
The callable fix itself looks right to me: platform check first with the arity heuristic as fallback is the correct order, and the v1-callable negative test plus the realistic rest-param shape in the regression test address everything from my last review. Ran this against both firebase-functions 4.9.0 and 7.2.5 and the routing behaves. One behavioral concern inline before this goes in, plus a couple of smaller ones.
Matching on platform sent v2 onRequest, onSchedule and blocking functions to wrapV2. Only callables need the trigger check, so the arity check handles the rest as before.
Co-authored-by: Jacob Cable <32874567+cabljac@users.noreply.github.com>
Co-authored-by: Jacob Cable <32874567+cabljac@users.noreply.github.com>
Co-authored-by: Jacob Cable <32874567+cabljac@users.noreply.github.com>
Co-authored-by: Jacob Cable <32874567+cabljac@users.noreply.github.com>
Fixes #310.
With firebase-functions 7,
wrap()treated v2onCallfunctions as v1 callables, so the handler received noauthor other request fields.This routes v2 callables to
wrapV2based on the function's trigger metadata instead of its parameter count.gcfv2take the v2 path.Tested with unit tests for v2 callables, v2
onRequestand v1 callables, and against this MRE.