GoogleCloudPlatform / esp-v2

A service proxy that provides API management capabilities using Google Service Infrastructure.
https://cloud.google.com/endpoints/
Apache License 2.0
268 stars 167 forks source link

Requests are not forwarded to the target if "address" URL includes a resource path #922

Open karolpivo opened 1 month ago

karolpivo commented 1 month ago

When path_translation: CONSTANT_ADDRESS is used at the endpoint level and the address includes a resource path the ESP does not forward the request to the target backend address.

With the below configuration the requests are forwarded (the target backend returns 404 because there is nothing at root path):

 /ourendpoint/healthz:
    get:
      summary: health check
      operationId: ourEndpointhHealthz
      x-google-backend:
        address: https://ourendpoint-2jxxxxdi7a-lm.a.run.app
        path_translation: CONSTANT_ADDRESS
        protocol: h2
      security: []
      responses:
        "200":
          description: success

Screenshot below shows the GCP logs. The behavior is as expected

image

With the below configuration the Cloud Endpoint / ESP simply returns a 404 and does not attempt to forward to the target

 /ourendpoint/healthz:
    get:
      summary: health check
      operationId: ourEndpointhHealthz
      x-google-backend:
        address: https://ourendpoint-2jxxxxdi7a-lm.a.run.app/healthz
        path_translation: CONSTANT_ADDRESS
        protocol: h2
      security: []
      responses:
        "200":
          description: success

Screenshot below shows the GCP logs.

image

Expected behavior:

ESP forwards the request to address: https://ourendpoint-2jxxxxdi7a-lm.a.run.app/healthz when
path_translation: CONSTANT_ADDRESS is set

This is how it should work according to documentation https://cloud.google.com/endpoints/docs/openapi/openapi-extensions#understanding_path_translation

Actual behavior

ESP returns a 404 and does not attempt to forward the request to the target backend when target address included a resource

Tested with 2.47.0 and 2.50.0

Please advise if this is a bug or me doing something wrong