Skip to content

[v8] Fix(curl): surface auth errors and avoid panic on nil HTTP response - #3838

Merged
prkalle merged 1 commit into
cloudfoundry:v8from
prkalle:fix/curl_auth_error_panic_v8
Aug 11, 2026
Merged

[v8] Fix(curl): surface auth errors and avoid panic on nil HTTP response#3838
prkalle merged 1 commit into
cloudfoundry:v8from
prkalle:fix/curl_auth_error_panic_v8

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

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?

@prkalle prkalle changed the title Fix(curl): surface auth errors and avoid panic on nil HTTP response [v8] Fix(curl): surface auth errors and avoid panic on nil HTTP response Aug 6, 2026
anujc25
anujc25 previously approved these changes Aug 11, 2026

@anujc25 anujc25 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks.

@prkalle
prkalle force-pushed the fix/curl_auth_error_panic_v8 branch from 44d0f78 to 2a99a8c Compare August 11, 2026 17:53
@prkalle
prkalle force-pushed the fix/curl_auth_error_panic_v8 branch from 2a99a8c to 0ac3ecc Compare August 11, 2026 18:29
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.

Also, sync .grype.yaml exclusions with main so check-cves ignores test fixtures

Signed-off-by: Prem Kumar Kalle <prem.kalle@broadcom.com>
@prkalle
prkalle force-pushed the fix/curl_auth_error_panic_v8 branch from 0ac3ecc to e569bcf Compare August 11, 2026 19:02
@prkalle
prkalle merged commit 0a094e0 into cloudfoundry:v8 Aug 11, 2026
17 checks passed
@prkalle

prkalle commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

Integration tests passed on earlier run: https://github.com/cloudfoundry/cli/actions/runs/31523051859

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.

2 participants