fix: add subdomain validator - #279
Merged
Merged
Conversation
betinacosta
commented
Aug 20, 2026
betinacosta
commented
Aug 20, 2026
betinacosta
commented
Aug 20, 2026
betinacosta
marked this pull request as ready for review
August 20, 2026 17:41
LucasAlvesSoares
requested changes
Aug 20, 2026
cassiofariasmachado
previously approved these changes
Aug 20, 2026
cassiofariasmachado
left a comment
Member
There was a problem hiding this comment.
Looks good to me. I've just added a minor suggestion
cassiofariasmachado
previously approved these changes
Aug 20, 2026
LucasAlvesSoares
previously approved these changes
Aug 20, 2026
betinacosta
dismissed stale reviews from LucasAlvesSoares and cassiofariasmachado
via
August 20, 2026 19:57
2d8b2fe
cassiofariasmachado
approved these changes
Aug 20, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Adds a shared
_validate_tenant_subdomainutility insap_cloud_sdk.core.url_utilsthat validates a tenant subdomain against RFC 1123 DNS label rules (ASCII letters, digits, and hyphens only; no leading/trailing hyphens; max 63 characters). The validator is now called before any token URL substitution in:AgentGatewayClient._resolve_tenant_subdomain(agentgateway/agw_client.py)TokenProvider.get_token(destination/_http.py)Auth._resolve_token_url(dms/_auth.py)A
ValueErrorwith a clear message is raised on invalid input instead of silently constructing a malformed URL.Related Issue
Closes #
Type of Change
How to Test
pip install -e .AgentGatewayClientwith an invalid subdomain:TokenProvider.get_token(tenant_subdomain="has.dot")in the destination module — expectValueError: Invalid tenant_subdomain.Auth._resolve_token_url("trailing-")in the DMS module — expectValueError: Invalid tenant_subdomain.Checklist
Additional Notes
The validator is intentionally kept internal (
_validate_tenant_subdomain) and lives insap_cloud_sdk.core.url_utilsfor reuse across all modules that accept atenant_subdomainparameter. PassingNoneis a no-op to accommodate callers that resolve the subdomain lazily or make it optional.