question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Functions Framework prevents developers from handling invalid params

See original GitHub issue

https://github.com/firebase/firebase-tools/issues/3891 seems to have a root cause in the functions framework.

To reproduce without Firebase:

const express = require('express');
const app = express();

app.get('/404', (req, res) => res.send('failed to work'));
app.get('**', (req, res) => res.send('working'));
app.use((err, req, res, next) => res.redirect('/404'));

module.exports.app = app;

if (require.main == module) {
  app.listen(8080);
}

If you run the file locally (no functions framework) and curl http://localhost:8080/%CO the user is redirected to http://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 with Bad Request

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
devlucemcommented, Mar 29, 2022

Thanks for your response @grant.

The middleware solution you offered is not supported and cannot be a workaround as the URL is checked before it gets to any cloud function. @inlined code shows the middleware sample.

1reaction
grantcommented, Mar 30, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting Cloud Functions - Google Cloud
Failure to do so may cause your function to stop executing at the wrong time. The error behavior. Your function exhibits one of...
Read more >
Google cloud function not handling sigint - Stack Overflow
Yeah, this is dumb. I don't have a solution, but my workaround is: Ctrl+C; Hit the URL from the browser. For some reason...
Read more >
Manage functions | Cloud Functions for Firebase - Google
... the Firebase CLI supports multiple arguments as well as functions groups, ... for a function that's handling production traffic, you can prevent...
Read more >
The 10 Most Common JavaScript Issues Developers Face
Powerful JavaScript-based libraries and frameworks for single page ... JavaScript Issue #6: Incorrect Use of Function Definitions Inside for Loops.
Read more >
Error Handling - Laravel - The PHP Framework For Web Artisans
All exceptions are handled by the App\Exceptions\Handler class. This class contains a register method where you may register custom exception reporting and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found