cloudfoundry / cloudfoundry/cli

cf map-route --path '/test;v' fails on second call

Open
#1,771 6 comments 0 reactions 1 assignee View on GitHub

@a-b is already working on this.

Since Oct 3, 2024.

bug contributions welcome unscheduled
Dominant language
Go
Stars
1.9k
Forks
990
Avg merge
1d 7h
Merged PRs (30d)
8

Description

  • I reviewed open and closed github issues that may be related to my problem.
  • I tried updating to the latest version of the CF CLI to see if it fixed my problem.
  • I attempted to run the command with CF_TRACE=1 to help debug the issue.
  • I am reporting a bug that others will be able to reproduce.
  • n/a If this is an issue for the v7 beta release, I've read through the official docs and the release notes.

Describe the bug and the command you saw an issue with

When mapping a route with a path that contains a semicolon, it succeeds the first time but fails on the second call.

What happened

stephan@WDFN34095835A:~/testapp$ cf map-route testapp1 cfapps.sap.hana.ondemand.com --hostname testapp94095 --path '/test;v'
Creating route testapp94095.cfapps.sap.hana.ondemand.com/test;v for org uptime / space test as D047883...
FAILED
Error resolving route:
Server error, status code: 400, error code: 210004, message: The path is taken: /test;v

Expected behavior
Call succeeds as it does for the path '/test':

stephan@WDFN34095835A:~/testapp$ cf map-route testapp1 cfapps.sap.hana.ondemand.com --hostname testapp94095 --path '/test'
Creating route testapp94095.cfapps.sap.hana.ondemand.com/test for org uptime / space test as D047883...
OK
Route testapp94095.cfapps.sap.hana.ondemand.com/test already exists
Adding route testapp94095.cfapps.sap.hana.ondemand.com/test to app testapp1 in org uptime / space test as D047883...
OK

To Reproduce

Given a simple hello world app:

mkdir testapp && cd testapp

cat > index.html <<'EOF'
<!DOCTYPE html>
<html>
<body>
<h1>Hello World</h1>
</body>
</html>
EOF
mkdir -p test
cp index.html test/

cf push testapp1 -p . -m 128M -b binary_buildpack -c 'python3 -m http.server 8080' --no-route --no-start

Map routes to the app using a path with and without a semicolon:

stephan@WDFN34095835A:~/testapp$ cf map-route testapp1 cfapps.sap.hana.ondemand.com --hostname testapp94095 --path /test
Creating route testapp94095.cfapps.sap.hana.ondemand.com/test for org uptime / space test as D047883...
OK
Adding route testapp94095.cfapps.sap.hana.ondemand.com/test to app testapp1 in org uptime / space test as D047883...
OK
stephan@WDFN34095835A:~/testapp$ cf map-route testapp1 cfapps.sap.hana.ondemand.com --hostname testapp94095 --path '/test;v'
Creating route testapp94095.cfapps.sap.hana.ondemand.com/test;v for org uptime / space test as D047883...
OK
Adding route testapp94095.cfapps.sap.hana.ondemand.com/test;v to app testapp1 in org uptime / space test as D047883...
OK

Start the app:

stephan@WDFN34095835A:~/testapp$ cf start testapp1
Starting app testapp1 in org uptime / space test as D047883...

Staging app and tracing logs...
...
Waiting for app to start...

name:              testapp1
requested state:   started
routes:            testapp94095.cfapps.sap.hana.ondemand.com/test, testapp94095.cfapps.sap.hana.ondemand.com/test;v
last uploaded:     Fri 30 Aug 11:27:35 DST 2019
stack:             cflinuxfs3
buildpacks:        binary

type:            web
instances:       1/1
memory usage:    128M
start command:   python3 -m http.server 8080
     state     since                  cpu    memory         disk        details
#0   running   2019-08-30T09:27:50Z   0.0%   2.1M of 128M   24K of 1G

Both routes are mapped and they work. The one with the semicolon returns a 404 which stems from the app. Don't know how the Python web server deals with a semicolon in the path but this is not relevant for the issue.

stephan@WDFN34095835A:~/testapp$ curl https://testapp94095.cfapps.sap.hana.ondemand.com/test/
<!DOCTYPE html>
<html>
<body>
<h1>Hello World</h1>
</body>
</html>
stephan@WDFN34095835A:~/testapp$ curl https://testapp94095.cfapps.sap.hana.ondemand.com/test/^C
stephan@WDFN34095835A:~/testapp$ curl 'https://testapp94095.cfapps.sap.hana.ondemand.com/test;v/'
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
        <title>Error response</title>
    </head>
    <body>
        <h1>Error response</h1>
        <p>Error code: 404</p>
        <p>Message: File not found.</p>
        <p>Error code explanation: HTTPStatus.NOT_FOUND - Nothing matches the given URI.</p>
    </body>
</html>

Now I rerun the route mapping (this may e.g. happen during a blue-green deployment):

stephan@WDFN34095835A:~/testapp$ cf map-route testapp1 cfapps.sap.hana.ondemand.com --hostname testapp94095 --path /test
Creating route testapp94095.cfapps.sap.hana.ondemand.com/test for org uptime / space test as D047883...
OK
Route testapp94095.cfapps.sap.hana.ondemand.com/test already exists
Adding route testapp94095.cfapps.sap.hana.ondemand.com/test to app testapp1 in org uptime / space test as D047883...
OK
stephan@WDFN34095835A:~/testapp$ cf map-route testapp1 cfapps.sap.hana.ondemand.com --hostname testapp94095 --path '/test;v'
Creating route testapp94095.cfapps.sap.hana.ondemand.com/test;v for org uptime / space test as D047883...
FAILED
Error resolving route:
Server error, status code: 400, error code: 210004, message: The path is taken: /test;v

The route mapping without semicolon succeeds but the one with a semicolon fails.

When running with -v I see the following CF API call failing:

REQUEST: [2019-08-30T13:43:13+02:00]
GET /v2/routes?inline-relations-depth=1&q=host%3Atestapp94095%3Bdomain_guid%3A9aa474f9-3f82-4967-a2e1-dfe0cd155064%3Bpath%3A%2Ftest%3Bv HTTP/1.1
Host: api.cf.sap.hana.ondemand.com
Accept: application/json
Authorization: [PRIVATE DATA HIDDEN]
Content-Type: application/json
User-Agent: go-cli 6.46.1+4934877ec.2019-08-23 / linux


RESPONSE: [2019-08-30T13:43:13+02:00]
HTTP/1.1 400 Bad Request
Connection: close
Content-Length: 114
Content-Type: application/json;charset=utf-8
Date: Fri, 30 Aug 2019 11:43:13 GMT
Server: nginx
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload;
X-Content-Type-Options: nosniff
X-Ratelimit-Limit: 40000
X-Ratelimit-Remaining: 39984
X-Ratelimit-Reset: 1567168899
X-Vcap-Request-Id: aeccd93f-5c10-4f29-719b-212b853069ca::35039c3f-335d-43a8-af8a-85d0336be3b9

{
  "description": "The query parameter is invalid: v",
  "error_code": "CF-BadQueryParameter",
  "code": 10005
}

FAILED
Error resolving route:
Server error, status code: 400, error code: 210004, message: The path is taken: /test;v

Looks like there is an issue with encoding (or with the decoding in CC) of the semicolon in the GET /v2/routes.

Provide more context

  • platform and shell details ( e.g. Mac OS X 10.11 iTerm)
    Win10 with bash (WSL)

  • version of the CLI you are running

stephan@WDFN34095835A:~/testapp$ cf --version
cf version 6.46.1+4934877ec.2019-08-23
  • version of the CC API Release you are on
    cf-deployment 11.0.0
stephan@WDFN34095835A:~/testapp$ cf api
api endpoint:   https://api.cf.sap.hana.ondemand.com
api version:    2.139.0

Note: As of January 2019, we no longer support API versions older than CF Release v284/CF Deployment v1.7.0 (CAPI Release: 1.46.0 (APIs 2.100.0 and 3.35.0).

Note: In order to complete the v7 beta cf CLI in a timely matter, we develop and test against the latest CAPI release candidate. When v7 cf CLI is generally available, we will start supporting official CC API releases again.

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.