Skip to content
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

Multivalue query param support on AWS lambda behind apigateway #3482

Open
leaumar opened this issue Oct 2, 2024 · 3 comments
Open

Multivalue query param support on AWS lambda behind apigateway #3482

leaumar opened this issue Oct 2, 2024 · 3 comments
Labels

Comments

@leaumar
Copy link

leaumar commented Oct 2, 2024

What version of Hono are you using?

4.6.3

What runtime/platform is your app running on?

AWS lambda node20

What steps can reproduce the bug?

Having an api gateway that calls a lambda where hono is listening, a request like GET http://.../helloworld?name=foo&name=bar results in our hono handlers only receiving the last multivalue, i.e. "bar" instead of ["foo","bar"] in a validator('query', ...) middleware. We're aware of the difference between ctx.req.query and ctx.req.queries but we don't use either, only ctx.req.valid('query').

We receive the full multivalue if we run the same hono app locally (so only apigateway and lambda are removed). We can also revert our "upgrade" from koa to hono on the current infrastructure (the same lambda config etc, just different js), and then koa gives us the full multivalue. So it seems to us this must be an issue in hono's integration with api gateway, not something wrong in our infrastructure or call.

What is the expected behavior?

validator('query', ...) should receive multivalue query params

What do you see instead?

only a single value is passed

Additional information

We had a glance at the hono code and believe https://github.com/honojs/hono/blob/main/src/adapter/aws-lambda/handler.ts#L285 is the relevant code, where multiValueQueryStringParameters would have to be used somehow.

But when we look at even the latest @types/aws-lambda, APIGatewayProxyEventV2 does not actually seem to have the field, contrary to what we understand from articles like this. Instead APIGatewayProxyEventMultiValueQueryStringParameters is used on APIGatewayProxyEventBase which APIGatewayProxyEventV2WithRequestContext doesn't extend. Our app does use an authorizer in front of our lambda and APIGatewayProxyWithLambdaAuthorizerEvent has multiValueQueryStringParameters, but we're not sure if that helps at all.

We don't really understand the reasoning in AWS' mess of payload types to be able to be more constructive, we never work with them, sorry. Maybe the most reasonable thing is for hono to just if ("multiValueQueryStringParameters" in event) { and parse it like here if true?

Thanks

@leaumar leaumar added the triage label Oct 2, 2024
@yusukebe
Copy link
Member

yusukebe commented Oct 4, 2024

Thanks @leaumar

@watany-dev @exoego @yiss or others. Can anyone handle this?

@yiss
Copy link
Contributor

yiss commented Oct 4, 2024

Thanks @leaumar I'll take look at it. What version of APIGateway are you using? V1 or v2?

@leaumar
Copy link
Author

leaumar commented Oct 4, 2024

@yiss our api is listed as a REST type so googling actually tells me it's a V1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants