Skip to content

Commit cac6bb3

Browse files
Add clarifying comments for urlparse edge case
- Added comments explaining why checking for '://' is necessary - urlparse treats 'example.com:8080' as having scheme='example.com', so we need to check for '://' to distinguish between real protocols and domain:port format - All 28 tests still passing Co-authored-by: sergioescalera <8428450+sergioescalera@users.noreply.github.com>
1 parent 6800198 commit cac6bb3

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

libraries/microsoft-agents-a365-observability-core/microsoft_agents_a365/observability/core/exporters/agent365_exporter.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ def export(self, spans: Sequence[ReadableSpan]) -> SpanExportResult:
105105
# Construct URL - if endpoint has a scheme (http:// or https://), use it as-is
106106
# Otherwise, prepend https://
107107
# Note: Check for "://" to distinguish between real protocols and domain:port format
108+
# (urlparse treats "example.com:8080" as having scheme="example.com")
108109
parsed = urlparse(endpoint)
109110
if parsed.scheme and "://" in endpoint:
110111
# Endpoint is a full URL, append path

libraries/microsoft-agents-a365-observability-core/microsoft_agents_a365/observability/core/exporters/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ def get_validated_domain_override() -> str | None:
159159
parsed = urlparse(domain_override)
160160

161161
# If scheme is present and looks like a protocol (contains //)
162+
# Note: We check for "://" because urlparse treats "example.com:8080" as having
163+
# scheme="example.com", but this is actually a domain with port, not a protocol.
162164
if parsed.scheme and "://" in domain_override:
163165
# Validate it's http or https
164166
if parsed.scheme not in ("http", "https"):

0 commit comments

Comments
 (0)