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

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

This branch has not been deployed

No deployments
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