Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra slash cleanup redirect looses HTTP request method #3335

Open
pregnor opened this issue Nov 19, 2020 · 0 comments
Open

Extra slash cleanup redirect looses HTTP request method #3335

pregnor opened this issue Nov 19, 2020 · 0 comments
Labels
kind/bug Something isn't working

Comments

@pregnor
Copy link
Member

pregnor commented Nov 19, 2020

Describe the bug

When an API request contains an extra / in the path (tested with .../pipeline//api/...) the cleanup redirect looses the request method (tested with POST -> GET). which causes unexpected behavior and silent "failure" in case of modifying operations (tested with node pool create).

INFO[2020-11-19T09:10:11+01:00]                                               correlation-id=d78cddca-5ccb-4f53-abb8-67bac6ca9acb ip=127.0.0.1 latency=39.792062ms method=POST path=/pipeline//api/v1/orgs/1/clusters/77/nodepools status=301 user-agent=PostmanRuntime/7.26.5
DEBU[2020-11-19T09:10:11+01:00] getting cluster from database                 cluster=77 organization=1
INFO[2020-11-19T09:10:11+01:00]                                               correlation-id=070a5c31-779b-4946-883d-95ecc92efd88 ip=127.0.0.1 latency=569.799673ms method=GET path=/pipeline/api/v1/orgs/1/clusters/77/nodepools status=200 user-agent=PostmanRuntime/7.26.5

Steps to reproduce the issue:

  1. Start a Pipeline instance.
  2. Create an EKS cluster.
  3. Issue the following command to initiate node pool creation with a request URL containing an extra /. (replace the token placeholder)
curl --location --request POST 'https://localhost:9090/pipeline//api/v1/orgs/1/clusters/77/nodepools' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ${TOKEN_PLACEHOLDER}' \
--data-raw '{
    "name":"node-pool",
    "size": 2,
    "instanceType": "t3a.nano",
    "autoscaling": {
  	  "enabled": true,
  	  "minSize": 1,
  	  "maxSize": 2
    },
    "spotPrice": "0.02",
    "volumeSize": 23
}'
  1. Observe the cluster not being updated.
  2. Observe the Pipeline logs to contain something similar to the description snippet above.

Expected behavior

The Pipeline should keep the request method when redirecting due to extra slashes.

Screenshots

Additional context

The new router replies to paths with // with a http redirect, which results in a GET request instead of POSTs in the go client (at the very least regarding trailing slashes).

@pregnor pregnor added the kind/bug Something isn't working label Nov 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant