fix(apigatewayv2): map $request.path to the request path without the stage (#8993)

AWS documents $request.path and ${request.path} as an HTTP API mapping
source that yields the request path without the stage name. The AWS
service integration validator accepted only $request.path.<name>, so
CreateIntegration rejected it, and ContextValueResolver had no case for
it, so it resolved to nothing. The resolver now returns
RequestContext.path(), which already excludes the stage, and the
validator accepts the bare source.

Closes #8991
This commit is contained in:
Ignas authored and GitHub committed 2026-11-19 17:43:41 -04:00
1 parent ade40d7940
commit 82ac1eabaa
4 files changed
+27 -2

No files matched your search

@@ -474,6 +474,20 @@ class ApiGatewayV2SqsSendMessageIntegrationTest {
});
}
@Test
void invokeResolvesRequestPathWithoutTheStage() {
String attributes = "{\"Path\":{\"DataType\":\"String\",\"StringValue\":\"${request.path}\"}}";
withSendMessageRoute("sqs-invoke-request-path",
queueUrl -> Map.of("QueueUrl", queueUrl, "MessageBody", "$request.path",
"MessageAttributes", attributes),
(sqs, queueUrl, api) -> {
given().post("/execute-api/" + api + "/test/send").then().statusCode(200);
Message message = onlyMessage(sqs, queueUrl);
assertThat(message.body(), equalTo("/send"));
assertThat(message.messageAttributes().get("Path").stringValue(), equalTo("/send"));
});
}
@Test
void invokeResolvesAccountDomainRequestIdAndRequestTimeContextVariables() {
String attributes = "{\"Account\":{\"DataType\":\"String\",\"StringValue\":\"${context.accountId}\"},"
@@ -99,6 +99,12 @@ class ContextValueResolverTest {
assertEquals("42", r.resolve("$request.path.id", c));
}
@Test
void requestPathWithoutNameResolvesToTheRequestPath() {
ContextValueResolver r = new ContextValueResolver();
assertEquals("/foo", r.resolve("$request.path", ctx(Map.of(), Map.of(), Map.of(), Map.of(), Map.of())));
}
@Test
void unknownExpressionReturnsNull() {
ContextValueResolver r = new ContextValueResolver();