Skip to content

[main][cherry-pick] Fix(curl): surface auth errors and avoid panic on nil HTTP response - #3839

Open
prkalle wants to merge 1 commit into
cloudfoundry:mainfrom
prkalle:fix/curl_auth_error_panic_main
Open

[main][cherry-pick] Fix(curl): surface auth errors and avoid panic on nil HTTP response#3839
prkalle wants to merge 1 commit into
cloudfoundry:mainfrom
prkalle:fix/curl_auth_error_panic_main

Conversation

@prkalle

@prkalle prkalle commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Description of the Change

This PR fixes cf curl command to surface auth errors and avoid panic on nil HTTP response

This PR is cherry-pick of #3838

Why Is This PR Valuable?

Thiis fixes the panic and surfaces underlying auth errors to users so the user sees a real message (e.g. "Bad credentials")

Applicable Issues

List any applicable GitHub Issues here

How Urgent Is The Change?

Medium

Other Relevant Parties

Who else is affected by the change?

MakeCurlRequest assumed that a non-nil error always came with an HTTP
response (e.g. a 4xx/5xx from the API). That assumption breaks when the
request fails before reaching the API — for example a token refresh /
client-credentials authentication failure in the UAA request wrapper,
which returns an error with a nil *http.Response.

In that case:
- Without --fail, the error was swallowed and cf curl printed empty
  output, giving the user no indication anything went wrong.
- With --fail, the code dereferenced httpResponse.StatusCode on the nil
  response and panicked.

Only surface CurlExit22Error when an HTTP response is actually present;
when the response is nil, return the underlying error directly so the
user sees a real message (e.g. "Bad credentials") and cf curl exits
cleanly instead of panicking. Existing behavior for real HTTP error
responses (print body by default, fail only with --fail) is unchanged.

Signed-off-by: Prem Kumar Kalle <prem.kalle@broadcom.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant