Skip to content

Conversation

@olucasfreitas
Copy link
Contributor

@olucasfreitas olucasfreitas commented Oct 21, 2025

Details

This PR fixes a usability issue where rosa create cluster --http-proxy was displaying unhelpful error messages when proxy passwords contained special characters like forward slashes, making it difficult for users to understand what was wrong with their input.


Fixed Behavior

  1. Run the command with a proxy password containing a forward slash:

    ./rosa create cluster --http-proxy "http://proxyuser:QvoZjyy/trkCiY5@10.0.0.161:8080"
  2. Now shows clear error message:

    E: Invalid http-proxy value 'http://proxyuser:QvoZjyy/trkCiY5@10.0.0.161:8080': 
       password contains special characters that need URL encoding
    

Additional Validations Added

  1. Spaces in URL - Detects and rejects URLs with spaces:

    ./rosa create cluster --http-proxy "http://proxy.example.com :8080"

    Output:

    E: Invalid http-proxy value 'http://proxy.example.com :8080': URL cannot contain spaces
    
  2. Invalid Port Range - Validates port numbers are between 1 and 65535:

    ./rosa create cluster --http-proxy "http://proxy.example.com:99999"

    Output:

    E: Invalid http-proxy value 'http://proxy.example.com:99999': port must be between 1 and 65535
    
  3. Multiple @ Symbols - Detects unencoded @ in passwords:

    ./rosa create cluster --http-proxy "http://user:pass@word@proxy.example.com:8080"

    Output:

    E: Invalid http-proxy value 'http://user:pass@word@proxy.example.com:8080': 
       password contains special characters that need URL encoding
    

The --https-proxy Flag Behavior

Using HTTPS scheme with --http-proxy continues to show the existing error:

./rosa create cluster --http-proxy "https://proxy.example.com:8080"

Output:

E: Expected http-proxy to have an http:// scheme

Ticket

Closes OCM-18900

@codecov
Copy link

codecov bot commented Oct 21, 2025

Codecov Report

❌ Patch coverage is 44.92754% with 38 lines in your changes missing coverage. Please review.
✅ Project coverage is 23.94%. Comparing base (c854a37) to head (770854f).
⚠️ Report is 10 commits behind head on master.

Files with missing lines Patch % Lines
pkg/helper/url/validation.go 0.00% 31 Missing ⚠️
pkg/ocm/helpers.go 88.57% 4 Missing ⚠️
cmd/create/cluster/cmd.go 0.00% 2 Missing ⚠️
cmd/edit/cluster/cmd.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3052      +/-   ##
==========================================
+ Coverage   23.91%   23.94%   +0.03%     
==========================================
  Files         317      318       +1     
  Lines       35202    35238      +36     
==========================================
+ Hits         8418     8439      +21     
- Misses      26143    26159      +16     
+ Partials      641      640       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 23, 2025
@olucasfreitas olucasfreitas force-pushed the OCM-18900 branch 2 times, most recently from 00638f4 to 120a803 Compare November 3, 2025 11:36
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 3, 2025
@olucasfreitas
Copy link
Contributor Author

/retest-required

@olucasfreitas olucasfreitas force-pushed the OCM-18900 branch 2 times, most recently from 2260456 to c6b94b4 Compare November 3, 2025 14:46
@olucasfreitas
Copy link
Contributor Author

/retest-required

@olucasfreitas
Copy link
Contributor Author

/retest-required

Copy link
Contributor

@hunterkepley hunterkepley left a comment

Choose a reason for hiding this comment

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

The test case in the bug ticket does not seem to pass:

E: parse "http://proxyuser:QvoZjyy/trkCiY5@10.0.0.161:8080": invalid port ":QvoZjyy" after host

I think there may be a bug in the parse code

@olucasfreitas
Copy link
Contributor Author

@hunterkepley I just did some tests here, and it seems to be working after the fix, did you test it with the branch locally ?

@olucasfreitas olucasfreitas force-pushed the OCM-18900 branch 2 times, most recently from 96029c9 to a50904c Compare November 3, 2025 19:49
@olucasfreitas
Copy link
Contributor Author

/retest-required

1 similar comment
@olucasfreitas
Copy link
Contributor Author

/retest-required

@olucasfreitas olucasfreitas force-pushed the OCM-18900 branch 2 times, most recently from 9502aa4 to 2637639 Compare November 5, 2025 15:38
@olucasfreitas olucasfreitas force-pushed the OCM-18900 branch 4 times, most recently from 560e392 to 3df4265 Compare November 13, 2025 19:27
@hunterkepley
Copy link
Contributor

/test all

@hunterkepley
Copy link
Contributor

/test e2e-presubmits-pr-rosa-sts-advanced

@hunterkepley
Copy link
Contributor

/test e2e-presubmits-pr-rosa-hcp-advanced

@hunterkepley
Copy link
Contributor

Some reason the e2e tests didn't run, I manually ran them so we can verify this MR didn't break any

@olucasfreitas
Copy link
Contributor Author

/retest

2 similar comments
@olucasfreitas
Copy link
Contributor Author

/retest

@olucasfreitas
Copy link
Contributor Author

/retest

@hunterkepley
Copy link
Contributor

/test e2e-presubmits-pr-rosa-hcp-advanced

@hunterkepley
Copy link
Contributor

/test e2e-presubmits-pr-rosa-sts-advanced

@olucasfreitas olucasfreitas force-pushed the OCM-18900 branch 2 times, most recently from 34c6edf to 875a547 Compare November 19, 2025 19:47
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 19, 2025

@olucasfreitas: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/coverage 2637639 link true /test coverage

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@olucasfreitas
Copy link
Contributor Author

/retest

@olucasfreitas olucasfreitas force-pushed the OCM-18900 branch 2 times, most recently from f7318dc to 3d09b7b Compare December 8, 2025 15:43
}

// Validate host format
_, _, err = net.SplitHostPort(parsedURL.Host)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you let me know why this is here?

Comment on lines 182 to 185
httpProxy := val.(string)
if httpProxy == "" {
return nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

won't this panic if val is not a string?

Copy link
Contributor

Choose a reason for hiding this comment

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

or a type which can be directly casted into one?

Copy link
Contributor

@hunterkepley hunterkepley Dec 8, 2025

Choose a reason for hiding this comment

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

I think there was some confusion on what I suggested in my comment here: #3052 (comment) because the guarding for it panicking was removed after

}

func ValidateHTTPSProxy(val interface{}) error {
httpsProxy := val.(string)
Copy link
Contributor

Choose a reason for hiding this comment

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

won't this panic?

Comment on lines 17 to 20
schemeIdx := strings.Index(urlString, "://")
if schemeIdx == -1 {
return &URLCredentialValidation{}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Im not sure I understand, we return an empty validation error when there is no ://?

#3052 (comment)

It looks like that previously, this returned an error but didn't have enough information in it. Now it has no information, could you let me know what this block of code should be doing? I might be just confused on it

Copy link
Contributor

Choose a reason for hiding this comment

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

Also when looking at the block of code above this one, I am even more confused on what this should be accomplishing

Comment on lines +23 to +26
atIdx := strings.LastIndex(rest, "@")
if atIdx == -1 {
return &URLCredentialValidation{}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

When an @ is not found, we return an empty validation error

What does this result in when the final error is printed out?

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.

4 participants