apollographql / router

A configurable, high-performance routing runtime for Apollo Federation 🚀
https://www.apollographql.com/docs/router/
Other
795 stars 266 forks source link

Unable to remove the Apollo-Expose-Query-Plan with header propagation remove regex #5021

Open machados opened 4 months ago

machados commented 4 months ago

Describe the bug I'm not entirely sure this is a bug however I'm not able to remove the Apollo-Expose-Query-Plan header from propagation unless I use remove.named.

To Reproduce Steps to reproduce the behavior:

  1. Setup router with header propagation with matching regex, propagate all request headers and then remove:
plugins:
  experimental.expose_query_plan: true
headers:
  all:
    request:
      - propagate:
          matching: .*
      - remove:
          matching: "^x-amzn-mtls-.*"
      - remove:
          matching: "^Apollo-.*"
          #named: Apollo-Expose-Query-Plan
  1. Submit request, the request should include the following headers (or similar):
Apollo-Expose-Query-Plan: true
x-amzn-mtls-clientcert-subject: CN=test,ou=web servers,o=organization,c=us
  1. On the subgraph server print/log the headers passed and notice that Apollo-Expose-Query-Plan is being propagated to the subgraphs, also notice that x-amzn-mtls-clientcert-subject is not being propagated correctly.

Expected behavior

I don't expect Apollo-Expose-Query-Plan to be propagated to the subgraphs by default since it is a header that the router should consume. However using the matching expression should remove it.

Output Inspect the headers passed to the subgraph server.

Desktop (please complete the following information):

Additional context I tried the following combinations:

headers:
  all:
    request:
      - propagate:
          matching: .*
      - remove:
          matching: "^x-amzn-mtls-.*|^Apollo-.*"

With the above the header was propagated.

headers:
  all:
    request:
      - propagate:
          matching: .*
      - remove:
          matching: "^(x-amzn-mtls-.*|^Apollo-.*)"

With the above the header was propagated.

headers:
  all:
    request:
      - propagate:
          matching: .*
      - remove:
          matching: "^x-amzn-mtls-.*"
      - remove:
          matching: "^Apollo-.*"

With the above the header was propagated.

headers:
  all:
    request:
      - propagate:
          matching: .*
      - remove:
          matching: "^x-amzn-mtls-.*"
      - remove:
          named: Apollo-Expose-Query-Plan

With the above the header was NOT propagated.

abernix commented 4 months ago

Given what you've written here, this should certainly be working. Have you tried any variations of casing (e.g., all lower-case), to see if that helps? I'll mark this as a bug, but your continued investigation is certainly useful. Thanks!