firebase-tools
firebase-tools copied to clipboard
fix(localFunction.ts): data was incorrectly not keyed to 'data' when passed into second argument of apiv2 post method
Description
Fixed a regression introduced from v12.9.1 to v13.0.0 where HTTPS Callable functions could not be executed from the Firebase Functions Shell. The following error would be shown when executing the function according to the public documentation:
{"severity":"WARNING","message":"Request body is missing data."} {"severity":"ERROR","message":"Error: Invalid request, unable to process.\n at entryFromArgs (/workspace/agora/node_modules/firebase-functions/lib/logger/index.js:130:19)\n at Object.error (/workspace/agora/node_modules/firebase-functions/lib/logger/index.js:116:11)\n at /workspace/agora/node_modules/firebase-functions/lib/common/providers/https.js:405:24\n at /workspace/agora/node_modules/firebase-functions/lib/common/providers/https.js:394:25\n at cors (/workspace/agora/node_modules/cors/lib/index.js:188:7)\n at /workspace/agora/node_modules/cors/lib/index.js:224:17\n at originCallback (/workspace/agora/node_modules/cors/lib/index.js:214:15)\n at /workspace/agora/node_modules/cors/lib/index.js:219:13\n at optionsCallback (/workspace/agora/node_modules/cors/lib/index.js:199:9)\n at corsMiddleware (/workspace/agora/node_modules/cors/lib/index.js:204:7)"}
A temporary workaround until this PR is merged in is to invoke the desired HTTPS Callable fuction with a top-level data
key for the argument passed into it's first parameter. Using the documentation's example, instead of:
myCallableFunction({'foo': 'bar'}) // Does not work
run:
myCallableFunction({ data: {'foo': 'bar'}})
Scenarios Tested
I manually tested the firebase functions:shell after my change. I believe localFunction.ts is only used by functionsShellCommandAction.js so this should be sufficient.
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
View this failed invocation of the CLA check for more information.
For the most up to date status, view the checks section at the bottom of the pull request.
@oconnorjoseph Can you add a changelog entry for this?
@oconnorjoseph Looks like the linter failed, can you run npm run format
and npm run test
locally to make sure everything passes?
@colerogers gettiing the same linting errors unfortunately. It appears to be because the linter was updated recently to disallow any
.
That being said, I'm getting the same number of successfully passing tests before and after the change when I run npm run test:compile && npm run mocha
.