Open mthmcalixto opened 1 month ago
I have noticed (and fixed) this issue a while back when updating my fork to align with hono's current update, you could patch the package for a workaround in the time being.
Advertising alert -
or you could use my fork: hono-adapter-aws-lambda, it also comes with a triggerProcessor
handle AWS trigger events like S3, EventBridge.
I'll proceed to create a PR for official Hono now.
Hi @mthmcalixto, coming back to this issue, graphql is using HTTP method and should be supported by the official adapter.
For your case, it is actually because you were including a JSON body with a GET method, which is not supported by the Web Standard Request, you should put it as query parameter for GET requests.
And in your test output on AWS Lambda, I guess you were testing with a simple payload like this?:
{ "hello": true }
,
This is an invalid request and will throw error.
You could check the AWS doc to see the valid payload for testing.
@NamesMT Yes, it seems that I passed an empty graphql body and this caused an internal error.
Body empty - Lambda URL:
Localhost:
What improvements are there in https://github.com/NamesMT/hono-adapter-aws-lambda?
That's weird, is "GraphQL query" in the Body a string that you put in or is it a placeholder by the API Client?,
From my testing, when the body is NOT EMPTY for GET requests, Lambda will returns a 502, and the localhost
will return a 400 with empty error, that is correct,
But if you are sure your body is empty then do the following debug steps:
If after that it still happens, could you setup a repo so that I can clone and test?
For my freshly set up repo, the GraphQL works fine with an empty body (400 with message), and will works when I pass it as a query parameter for GET request, example:
local:
Lambda:
Or you know what? You could just screw, never use GET requests and use only POST requests, GraphQL also recommend POST requests for easier sending of the query payload.
For my adapter fork,
Currently, it allows unknown
events to be processed by v1Processor instead of throwing at isALBEvent check and it adds a triggerProcessor
to support custom invokations following the format: { "eventSource": "string" }
and AWS event sources like S3, EventBridge,...
@NamesMT try to put the query empty and do a GET.
This should return a json error, not an internal error.
Here it stops you from continuing, because it returned 502:
Hi @mthmcalixto, this is my response if I put the query empty and do a GET (Lambda):
The response is a proper 400 with message, not a 502
Hi @mthmcalixto, this is my response if I put the query empty and do a GET (Lambda):
The response is a proper 400 with message, not a 502
@mthmcalixto
It will return 400 with message if the body is selected as None
,
If the body is selected as GraphQL
, even with nothing inputted, httpie
will still include the JSON body of: {"query": ""}
, so this issue is basically user error / HTTP client error.
You could have checked it the whole time in the
Request
tab 🤦🏽
You could have checked it the whole time in the tab 🤦🏽
Request
but it shouldn't return a 502 error, but a 400 error
Hi,
The problem here is by web standards, HTTP GET requests cannot contains a Body, and HTTPie will includes a body of {"query": ""}
even when you have inputted nothing with GraphQL
mode selected, so the request is invalid and therefor will cause error on Lambda while parsing the request.
Hi, The problem here is by web standards, HTTP GET requests cannot contains a Body, and HTTPie will includes a body of
{"query": ""}
even when you have inputted nothing withGraphQL
mode selected, so the request is invalid and therefor will cause error on Lambda while parsing the request.
That's exactly the error I'm saying, it should return 400, not a 502.
The error is not handled.
Having similar issue.
On another note, in just using the Hello World example for AWS lambda in https://hono.dev/getting-started/aws-lambda
, this problem can be also replicated. Reverted as of the moment as this issue isn't present at least on v4.2.9
with a couple of drawbacks like this issue ( which was fixed on v4.4.1
).
Hi @zerijodmanguardia,
Would greatly appreciate it if you could have the time to create an issue detailing your issue :D
A TL;DR FYI on the original issue for later comers, the issue was caused by user error, not Hono, more specifically, the HTTP client he is using: "HTTPie" will includes a JSON body with GET request, even when nothing is inputted, this will throw an error on AWS Lambda because it is not allowed according to web standards.
What version of Hono are you using?
4.3.7
What runtime/platform is your app running on?
Lambda
What steps can reproduce the bug?
Any idea why the GET method doesn't work?
What is the expected behavior?
What do you see instead?
Additional information
No response