com.amazonaws.apigateway.request.context missing in backend @RestController
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 42/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- aws, java, spring-boot
Hướng nghiên cứu
Bắt đầu với entry point LambdaHandler và GeographicAddressController được nêu trong issue, sau đó theo dõi cách API Gateway request context được cung cấp cho các thuộc tính của Spring controller. Tái hiện request bằng các phiên bản Spring Boot và container được liệt kê; hoàn tất khi @RequestAttribute nhận được AwsProxyRequestContext, bao gồm cả các chi tiết của authorizer, thay vì null.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Issue: com.amazonaws.apigateway.request.context missing in backend @RestController
To help us debug your issue fill in the basic information below using the options provided
Serverless Java Container version: 2.1.4
Implementations: Spring Boot 3
Framework version: SpringBoot 3.5.3
Frontend service: REST API / API Gateway Proxy Request
Deployment method: SAM
Description
When using Spring Boot 3.5.3 with aws-serverless-java-container-springboot3:2.1.4,
the AwsProxyRequestContext is not being injected into a controller method when annotated with:
@RequestAttribute("com.amazonaws.apigateway.request.context")
This attribute is expected to contain the API Gateway request context, but instead it is always null.
Lambda Handler
import com.amazonaws.serverless.exceptions.ContainerInitializationException;
import com.amazonaws.serverless.proxy.internal.LambdaContainerHandler;
import com.amazonaws.serverless.proxy.model.AwsProxyRequest;
import com.amazonaws.serverless.proxy.model.AwsProxyResponse;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestStreamHandler;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class LambdaHandler implements RequestStreamHandler {
private static final SpringBootLambdaContainerHandler<AwsProxyRequest, AwsProxyResponse> handler;
static {
try {
handler = new SpringBootProxyHandlerBuilder<AwsProxyRequest>()
.defaultProxy()
.initializationWrapper(new InitializationWrapper())
.springBootApplication(Application.class)
.buildAndInitialize();
} catch (ContainerInitializationException e) {
throw new LambdaException("Could not initialize Lambda. ", e);
}
}
@Override
public void handleRequest(InputStream inputStream, OutputStream outputStream, Context context) throws IOException {
handler.proxyStream(inputStream, outputStream, context);
}
}
Controller
import com.amazonaws.serverless.proxy.model.AwsProxyRequestContext;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@RestController
public class GeographicAddressController {
private static final String API_GATEWAY_CONTEXT_PROPERTY = "com.amazonaws.apigateway.request.context";
@GetMapping(path = "/geographicAddress", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Object> get(
final @RequestHeader HttpHeaders reqHeaders,
final @RequestParam Map<String, String> params,
final @RequestAttribute(value = API_GATEWAY_CONTEXT_PROPERTY, required = false) AwsProxyRequestContext requestContext
) {
// requestContext is always null, I would like to get AwsProxyRequestContext , and authorizer details
return ResponseEntity.ok().build();
}
}
Expected Behavior
The requestContext parameter should be populated with the AwsProxyRequestContext extracted from the incoming API Gateway event.
Actual Behavior
requestContext is always null inside the controller method.
Steps to Reproduce
- Deploy a
Spring Boot 3.5.3application withaws-serverless-java-container-springboot3:2.1.4. - Use the Lambda handler shown above.
- Add a controller method with
@RequestAttribute("com.amazonaws.apigateway.request.context"). - Invoke the API Gateway endpoint.
- Observe that
requestContextis alwaysnull.
- Ngôn ngữ chính
- Java
- Star
- 1.6k
- Fork
- 575
- Merge trung bình
- 1 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 12
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của aws/serverless-java-container
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
aws/serverless-java-container#1729 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
aws/serverless-java-container#1715 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Support for API Gateway mTLS clientCert fieldCó thể đã có người làm @2748109647 đã nhận 10 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 48/100
aws/serverless-java-container#1726 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
aws/serverless-java-container#1579 · 3 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 42/100
aws/serverless-java-container#1568 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của aws/serverless-java-container
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
ls1intum/thesis-management#1473 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
LunaDeerMC/Dominion#301 · 1 bình luận ·
-
[FEATURE] Expose external refresh, node-level translog and warmer statsCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởuntriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
opensearch-project/opensearch-prometheus-exporter#680 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100