-
Notifications
You must be signed in to change notification settings - Fork 130
created util method to normalise http protocol in http path #724
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
Open
nikhilsuri-db
wants to merge
10
commits into
main
Choose a base branch
from
PECOBLR-1446
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+234
−61
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
14915d2
created util method to normalise http protocol in http path
nikhilsuri-db 81ec814
Added impacted files using util method
nikhilsuri-db ef4f92c
Fixed linting issues
nikhilsuri-db e982615
fixed broken test with mock host string
nikhilsuri-db 5ae79ce
mocked http client
nikhilsuri-db cca26eb
made case sensitive check in url utils
nikhilsuri-db a5c698c
linting issue resolved
nikhilsuri-db 5f9954f
removed unnecessary md files
nikhilsuri-db 23af8e2
made test readbale
nikhilsuri-db f8dad10
changes done in auth util as well as sea http
nikhilsuri-db File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| """ | ||
| URL utility functions for the Databricks SQL connector. | ||
| """ | ||
|
|
||
|
|
||
| def normalize_host_with_protocol(host: str) -> str: | ||
| """ | ||
| Normalize a connection hostname by ensuring it has a protocol. | ||
|
|
||
| This is useful for handling cases where users may provide hostnames with or without protocols | ||
| (common with dbt-databricks users copying URLs from their browser). | ||
|
|
||
| Args: | ||
| host: Connection hostname which may or may not include a protocol prefix (https:// or http://) | ||
nikhilsuri-db marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| and may or may not have a trailing slash | ||
|
|
||
| Returns: | ||
| Normalized hostname with protocol prefix and no trailing slashes | ||
|
|
||
| Examples: | ||
| normalize_host_with_protocol("myserver.com") -> "https://myserver.com" | ||
| normalize_host_with_protocol("https://myserver.com") -> "https://myserver.com" | ||
| normalize_host_with_protocol("HTTPS://myserver.com/") -> "https://myserver.com" | ||
| normalize_host_with_protocol("http://localhost:8080/") -> "http://localhost:8080" | ||
|
|
||
| Raises: | ||
| ValueError: If host is None or empty string | ||
| """ | ||
| # Handle None or empty host | ||
| if not host or not host.strip(): | ||
| raise ValueError("Host cannot be None or empty") | ||
|
|
||
| # Remove trailing slashes | ||
| host = host.rstrip("/") | ||
nikhilsuri-db marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Add protocol if not present (case-insensitive check) | ||
| host_lower = host.lower() | ||
| if not host_lower.startswith("https://") and not host_lower.startswith("http://"): | ||
| host = f"https://{host}" | ||
| elif host_lower.startswith("https://") or host_lower.startswith("http://"): | ||
| # Normalize protocol to lowercase | ||
| protocol_end = host.index("://") + 3 | ||
| host = host[:protocol_end].lower() + host[protocol_end:] | ||
|
|
||
| return host | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was rechecking this piece of code : auth_utils.py and thrift_backend - Has proper check on this already. should we use this util instead?
Also, the sea flow looks incorrect at the moment : backend/sea/utils/http_client.py
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, we can consolidate the auth_util to url_utils 👍 but thrift_backend seems very inline modification, do not want to touch it in current PR scope.
Regarding Sea - Fixed by using the new url_utils