[event] Improve error handling on empty/invalid HTTP payload.
Closed this issue · 0 comments
grayside commented
Current Behavior
When an HTTP request is sent to a background function with no value, the following error is thrown:
2020/06/03 19:12:02 [error] 29#29: *3 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught RuntimeException: Could not parse request body: Syntax error in /srv/vendor/google/cloud-functions-framework/src/BackgroundFunctionWrapper.php:36
Stack trace:
#0 /srv/vendor/google/cloud-functions-framework/src/Invoker.php(53): Google\CloudFunctions\BackgroundFunctionWrapper->execute(Object(GuzzleHttp\Psr7\ServerRequest))
#1 /srv/vendor/google/cloud-functions-framework/router.php(75): Google\CloudFunctions\Invoker->handle()
#2 /srv/vendor/google/cloud-functions-framework/router.php(77): {closure}()
#3 {main}
thrown in /srv/vendor/google/cloud-functions-framework/src/BackgroundFunctionWrapper.php on line 36" while reading response header from upstream, client: 172.17.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/tmp/google-config/php-fpm.sock:", host: "localhost:8083"
When I saw this error, I thought it strange that a language syntax error could be encountered at runtime.
Proposal
Split the error handling and throw warnings about "Missing event payload" and "Invalid JSON syntax in event payload".