cli
cli copied to clipboard
Trailing Slash in api url leads to failure in cf curl
Hello,
I discovered the following unexpected behaviour when using the cf curl command.
Everything works as expected, when logging in the following way:
cf api <the_api_url>
cf auth --origin uaa <username> <password>
Then, executing cf curl v3/service_brokers
returns all service brokers and cf curl v3/service_brokers?names=some_name
in my case returns
{"pagination":{"total_results":0,"total_pages":1,"first":{"href":"https://api.<redacted>/v3/service_brokers?names=some_name\u0026page=1\u0026per_page=50"},"last":{"href":"https://api.<redacted>/v3/service_brokers?names=some_name\u0026page=1\u0026per_page=50"},"next":null,"previous":null},"resources":[]}
and thats totally fine.
If in the cf api
command the url has a trailing slash cf api <the_api_url>/
the cf curl
command behaves quite unexpected. The cf api
command does not return any error or warning if doing so which means, you do not see any issue to enter the api url with a trailing slash as a user.
The command cf curl v3/service_brokers
still works but cf curl v3/service_brokers?names=some_name
returns
{"errors":[{"detail":"Unknown request","title":"CF-NotFound","code":10000}]}
My assumption is, that internally, the api url is concatenated with the path from the curl command which leads to a double slash. This is an unexpected behaviour from my perspective and should be fixed, either by trowing an error if the url contains a trailing slash or, and I think that this would be the better solution, parse the url and remove the trailing slash when calling cf api
.
I am running on cf version 8.7.3
Kind regards, Oliver