Skip to content

fix: is_same_host returns False for bare hostnames (no scheme) - #956

Open
Shubham-Padkonde wants to merge 1 commit into
databricks:mainfrom
Shubham-Padkonde:fix/is-same-host-bare-hostname
Open

Shubham-Padkonde wants to merge 1 commit into
databricks:mainfrom
Shubham-Padkonde:fix/is-same-host-bare-hostname

Conversation

@Shubham-Padkonde

Copy link
Copy Markdown

urlparse treats a string with no scheme as an opaque path, so urlparse("host.example.com").netloc is "" while
urlparse("https://host.example.com").netloc is "host.example.com". is_same_host therefore returned False whenever one of its arguments lacked a scheme — for example a JWT iss claim stored as a bare hostname vs. self.hostname which is always normalized with https://.

Fix: extract a nested helper _extract_host that re-parses with a dummy "https://" prefix when the initial parse yields an empty netloc, recovering the actual hostname in the bare-hostname case. Also normalises extracted hosts to lowercase for a consistent comparison.

Add four new parametrize cases to test_is_same_host covering the previously failing mixed-scheme and bare-vs-bare comparisons.

What type of PR is this?

  • Refactor
  • Feature
  • Bug Fix
  • Other

Description

How is this tested?

  • Unit tests
  • E2E Tests
  • Manually
  • N/A

Related Tickets & Documents

Copilot AI lite review requested due to automatic review settings September 24, 2026 04:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

urlparse treats a string with no scheme as an opaque path, so
urlparse("host.example.com").netloc is "" while
urlparse("https://host.example.com").netloc is "host.example.com".
is_same_host therefore returned False whenever one of its arguments
lacked a scheme — for example a JWT iss claim stored as a bare
hostname vs. self.hostname which is always normalized with https://.

Fix: extract a nested helper _extract_host that re-parses with a
dummy "https://" prefix when the initial parse yields an empty
netloc, recovering the actual hostname in the bare-hostname case.
Also normalises extracted hosts to lowercase for a consistent
comparison.

Add four new parametrize cases to test_is_same_host covering the
previously failing mixed-scheme and bare-vs-bare comparisons.

Signed-off-by: Shubham-Padkonde <shubhampadkonde12@gmail.com>
@Shubham-Padkonde
Shubham-Padkonde force-pushed the fix/is-same-host-bare-hostname branch from 7879395 to 045720b Compare October 2, 2026 13:29

This branch had an error being deployed

1 failed (outdated) deployment
azure-prod — 7879395d Deployed Sep 30, 2026 by Shubham-Padkonde via lts-install (16.4.x-scala2.12, pyarrow) #342
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.

3 participants