Skip to content

Extra slash cleanup redirect looses HTTP request method  #3335

@pregnor

Description

@pregnor

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions