spring-cloud / spring-cloud/spring-cloud-gateway

Webflux: GATEWAY_ORIGINAL_REQUEST_URL_ATTR not set in ForwardRoutingFilter

Open
#4,053 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

waiting-for-triage
Dominant language
Java
Stars
4.9k
Forks
3.5k
Avg merge
20h 57m
Merged PRs (30d)
8

Description

This is a re-report of https://github.com/spring-cloud/spring-cloud-gateway/issues/3510.

Describe the bug
The documentation for Forward Routing Filter states:

The unmodified original URL is appended to the list in the ServerWebExchangeUtils.GATEWAY_ORIGINAL_REQUEST_URL_ATTR attribute

This is not the case, or I am misunderstsanding. The controller eventually handling the request (i.e. the one being forwarded to) does not see this attribute on the ServerWebExchange.

Sample
I have attached a minimal application that recreates the behavior.

It consists roughly of:

# application.yaml
spring:
  cloud:
    gateway:
      server:
        webflux:
          routes:
            - id: test
              uri: forward:/internal/test
              predicates:
                - Path=/test/**
                - Method=GET
@GetMapping("/internal/test")
public TestResponse test(ServerWebExchange exchange) {
  Set<URI> originalUris = exchange.getAttribute(ServerWebExchangeUtils.GATEWAY_ORIGINAL_REQUEST_URL_ATTR);
  return new TestResponse(true, originalUris);
}

and a test expecting the response to contain a non-null originalUris value.

forward-bug.zip

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the attached minimal application and start by tracing ForwardRoutingFilter with the documented GATEWAY_ORIGINAL_REQUEST_URL_ATTR behavior in mind. Compare the exchange seen by the forwarded controller with the issue's expected test result; done means the controller observes a non-null original URI attribute as documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring, spring-boot
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.