-
Notifications
You must be signed in to change notification settings - Fork 82
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
Changed behaviour of routing evalution between Micronaut 3 and 4? #2078
Comments
are you working with API Gateway Urls or with a custom domain? We have a dependency to help you work with API Gateway which I would recommend you to use instead of using context-page. |
we use a custom domain with api mappings. |
tested with the depcrecated "io.micronaut.function.aws.proxy.MicronautLambdaHandler" again, but it didn't change the outcome. |
so, the issue is you use API Gateway with custom domain and you want also to use context-path and it does not work as expected? |
I absolutely don't want to configure context-path in my lambda, it breaks our code. :) The issue is, in the Lambda event sent fromthe API Gateway.
I want Micronaut to continue use the "resource"-property to evaluate routing so that its possible to add the lambda to whatever custom domain and api-mapping I want, as using "path" which contain the api-mapping from API Gateway "locks" the lambda to be used just in that API.. Reverting to the old behaviour of Micronaut3, with using the resource-property to route incoming request would is prefered and would make the lambda much more reusable between difference API Gateway apis. |
do you have an example of how you are setting API Gateway in console or better in CDK code? |
We are importing the openapi spec from micronaut to create the APIs. I will find an example. This is how the OpenApi is generated from Micronaut, by adding Extensions for API- Gateway config to the source code.
Its imported by running terraform with the openapi spec as body,
and in addition we create
This will create a api-gateway api https://www.exampe.com/myapp that listens for incoming Events sent to the lambda will look like this
It will work in Micronaut 3, but crash in Micronaut 4. |
What class in Micronaut is parsing and handling the evaluation of the incoming Lambda event content? |
Seems like the change was done here Line 63 in bb8410b
|
I'm experiencing this issue too, and it seems like a regression from this fix #19 |
Expected Behavior
In Micronaut 4 , when deploying application type lambda in the API Gateway, the API mapping in the gateway should be ignored, like it is in Micronaut 3.
Actual Behaviour
Its a REST API accessibly via AWS API Gateway under the api mapping
/myapp
and uses the Application type withio.micronaut.function.aws.proxy.payload1.ApiGatewayProxyRequestEventFunction
routing in Micronaut to route to the correct@Controller
in the lambda.When testing this from postman to the api-gateway url, the request event looks like this
Notice that the API Gateway has added the API mapping to the
path
property, but not to theresource
property.This works in Micronaut 3 using
io.micronaut.function.aws.proxy.MicronautLambdaHandler
because it seems like Micronaut 3 uses the"resource": "/users"
property to evaluate the routing to correct method in the Controller.When using Micronaut 3, I can change the API mapping of my Lambda in API Gateway to whatever I need and deploy the same lambda in different api endpoint, and it will still call my Users controller and return the expected response, because it use the "resource" property to route to map to the Users Controller, Micronaut 3 ignores the path the lambda is hosted on in the API Gateway.
The raw json event payload received by the Lambda looks like this
Upgrading to Micronaut 4, this will break and return 404 instead.
In Micronaut 4 using the handler
io.micronaut.function.aws.proxy.payload1.ApiGatewayProxyRequestEventFunction
it seems like it has been changed which property in the request event that is evaluated for routing and its now thepath
-property instead, which by API Gateway includes the context-root set in the api mapping from Api Gateway, which means that the context root in the lambdas application.yml must now be set to the same.A request as the one below will work in Micronaut 3, but not in Micronaut 4.
This means that the same lambda can't be used from different API Gatway APIs in Micronaut4 but could in Micronaut3.
Steps To Reproduce
io.micronaut.function.aws.proxy.MicronautLambdaHandler
withcontext-root: /
/users
and return 200 ok.io.micronaut.function.aws.proxy.payload1.ApiGatewayProxyRequestEventFunction
Environment Information
Example Application
No response
Version
4.3.4
The text was updated successfully, but these errors were encountered: