-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Functions Framework prevents developers from handling invalid params #409
Comments
CC @DevLucem , this will be the new home for firebase-tools#3891 |
Hi @inlined, thanks for the issue. Can you please provide more details, including full repro steps in this issue (not linked issues)? For example, the sample above uses Express and Express routing, not the Functions Framework. |
Thank you @inlined @grant Here is the most basic code from cloud functions hello world
For this case, the unauthenticated invocations option has to be enabled as it is a publicly accessible website Using the trigger URL for any method should work and will work until you add |
Hi @DevLucem, Here's the full repro:
exports.helloWorld = (req, res) => {
let message = req.query.message || req.body.message || 'Hello World!';
res.status(200).send(message);
};
{
"main": "index.js",
"dependencies": {
"@google-cloud/functions-framework": "^3.0.0"
}
}
The full curl reveals the stacktrace:
It is expected that the function wrapper handled the HTTP request to produce the There currently is no possible way to intercept exceptions like invalid URLs. If you'd like there to be a way, can you please file a GitHub issue in the main FF repo? https://github.com/GoogleCloudPlatform/functions-framework In your application, if you really wanted to, you can workaround this issue by providing a custom middleware, although that is not officially supported. Here's a general handler method, and post for middleware:
I'm going to close this issue out, but if there are pending questions, please let us know. Hope this info is helpful. |
I also have tried a middleware solution and I can confirm that it doesn't work. |
Thanks. What would you like the dev experience to be ideally? Expected behavior? Can you write that out? I'm hearing you'd like to still invoke the function, but the server cannot accept a bad request. An error handler? Express sets up the router and processes params a bit out of our control. |
I expected for middleware workaround to solve this problem and honestly I can not come up with any idea of how this should behave. |
To solve this, I think we'd need to support a lifecycle hook to handle I wrote my thoughts here: GoogleCloudPlatform/functions-framework#56 Similar: https://stackoverflow.com/a/31576777 |
Closing this as it's tracked upstream against the FF spec. |
firebase/firebase-tools#3891 seems to have a root cause in the functions framework.
To reproduce without Firebase:
If you run the file locally (no functions framework) and
curl http://localhost:8080/%CO
the user is redirected tohttp://localhost:8080/404
.If you deploy the function and CURL the repo (temporarily) at
https://us-central1-inlined-junkdrawer.cloudfunctions.net/param-encoding/%C0
, the functions framework rejects the request before it ever hits customer code withBad Request
The text was updated successfully, but these errors were encountered: