-
Notifications
You must be signed in to change notification settings - Fork 6
Fix domain override validation to accept valid URLs with protocols #112
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
base: main
Are you sure you want to change the base?
Conversation
- Updated get_validated_domain_override() to accept both domain-only and full URL formats - Added URL parsing logic to validate http/https protocols - Updated URL construction in agent365_exporter.py to handle both formats - Added comprehensive unit tests for domain validation - Updated existing tests to reflect new validation behavior Co-authored-by: sergioescalera <[email protected]>
- Updated URL construction logic to check for '://' to distinguish between real protocols and domain:port format - Added test for domain with port (example.com:8080) to ensure https:// is prepended correctly - All 28 tests pass Co-authored-by: sergioescalera <[email protected]>
- 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 <[email protected]>
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.
Pull request overview
This PR fixes the validation logic for the A365_OBSERVABILITY_DOMAIN_OVERRIDE environment variable to accept URLs with protocols (http/https) in addition to domain-only formats. Previously, the validation incorrectly rejected all URLs containing "://", even though the parameter represents a complete endpoint URL rather than just a domain name.
Changes:
- Updated validation in
utils.pyto accept both full URLs (with http/https protocols) and domain-only formats (with optional ports) - Modified URL construction in
agent365_exporter.pyto handle both full URLs and domain-only values correctly - Added comprehensive unit and integration tests covering various URL format edge cases
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
libraries/microsoft-agents-a365-observability-core/microsoft_agents_a365/observability/core/exporters/utils.py |
Updated get_validated_domain_override() to accept http/https URLs while rejecting invalid protocols and malformed URLs; added urlparse import |
libraries/microsoft-agents-a365-observability-core/microsoft_agents_a365/observability/core/exporters/agent365_exporter.py |
Modified URL construction logic to use full URLs as-is when protocol present, or prepend https:// for domain-only formats; added urlparse import |
tests/observability/core/exporters/test_utils.py |
Added 11 unit tests covering validation edge cases including various URL formats, protocols, and invalid inputs |
tests/observability/core/test_agent365_exporter.py |
Added 3 integration tests for URL override scenarios with https, http, and domain:port formats; updated existing test to use invalid protocol (ftp) |
...5-observability-core/microsoft_agents_a365/observability/core/exporters/agent365_exporter.py
Outdated
Show resolved
Hide resolved
...5-observability-core/microsoft_agents_a365/observability/core/exporters/agent365_exporter.py
Outdated
Show resolved
Hide resolved
...5-observability-core/microsoft_agents_a365/observability/core/exporters/agent365_exporter.py
Show resolved
Hide resolved
...t-agents-a365-observability-core/microsoft_agents_a365/observability/core/exporters/utils.py
Outdated
Show resolved
Hide resolved
...t-agents-a365-observability-core/microsoft_agents_a365/observability/core/exporters/utils.py
Outdated
Show resolved
Hide resolved
...t-agents-a365-observability-core/microsoft_agents_a365/observability/core/exporters/utils.py
Outdated
Show resolved
Hide resolved
|
@copilot - fic the lint error run below and fix errors |
- Remove trailing whitespace (auto-formatted with ruff) - Add validation for malformed URLs like "http:8080" (missing slashes) - Update comment to clarify "domain with optional port" instead of "just a domain" - Add tests for malformed URL edge cases - All 30 tests passing Co-authored-by: nikhilNava <[email protected]>
91dad5c
Fixed in commit 91dad5c - ran Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Fix domain override validation to accept valid URLs
get_validated_domain_override()to validate URLs instead of rejecting themSummary
Fixed the validation logic in
get_validated_domain_override()to accept valid URLs with protocols (http://, https://) instead of rejecting them. The parameter represents an endpoint with protocol, not just a domain name.Code Review Feedback Addressed
Supported Formats
✅ Valid (Accepted):
example.com→ prependshttps://example.com:8080→ prependshttps://http://localhost:8080→ used as-ishttps://example.com→ used as-is❌ Invalid (Rejected):
ftp://example.com→ invalid protocolexample.com/path→ domain with pathhttps://→ protocol without hostnamehttp:8080→ malformed URL (missing slashes)Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.