Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ignore empty string when setting endpoint #609

Closed
wants to merge 1 commit into from
Closed

Conversation

jooola
Copy link
Member

@jooola jooola commented Mar 11, 2025

Since we cannot return an error, we should never accept an empty string as a valid endpoint.

The current behavior is difficult to debug, when we set the endpoint to an empty string, the client fails with the unsupported protocol scheme erorr.

This might be a bit magic, but between having a panic and ignore the input string, I prefer the latter.

This is a great candidate for a potential v3 of the client, were we can validate options.

@jooola jooola requested a review from a team as a code owner March 11, 2025 16:25
Copy link

codecov bot commented Mar 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.83%. Comparing base (0deb045) to head (70c0f36).
Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #609      +/-   ##
==========================================
+ Coverage   67.68%   67.83%   +0.14%     
==========================================
  Files          48       48              
  Lines        5010     5011       +1     
==========================================
+ Hits         3391     3399       +8     
+ Misses       1198     1193       -5     
+ Partials      421      419       -2     

☔ 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.

@jooola jooola requested a review from apricote March 11, 2025 18:28
@@ -124,7 +124,9 @@ type ClientOption func(*Client)
// WithEndpoint configures a Client to use the specified API endpoint.
Copy link
Member Author

Choose a reason for hiding this comment

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

I'll update the docs with the new behavior if we agree on it.

@apricote
Copy link
Member

This might be a bit magic, but between having a panic and ignore the input string, I prefer the latter.

I am undecided on that. I think silently ignoring this configuration error is bad, as it might lead to a client talking to the wrong endpoint. On the other hand this is probably unused by nearly everyone outside of Hetzner Cloud, so it does not really matter much.

What do you think about a warning message to stderr in this case? This makes it at least discoverable that something unintended is happening.

@jooola
Copy link
Member Author

jooola commented Mar 13, 2025

I would wait for the v3 to find the best solution and not implement a short term solution. Maybe with the event recorder we could send such thing but it is not there yet.

Closing for now;

@jooola jooola closed this Mar 13, 2025
@jooola jooola deleted the panic-endpoint branch March 13, 2025 15:05
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