Add server URL normalization for flexible server_url input#122
Draft
chris-freeman-glean wants to merge 1 commit intomainfrom
Draft
Add server URL normalization for flexible server_url input#122chris-freeman-glean wants to merge 1 commit intomainfrom
chris-freeman-glean wants to merge 1 commit intomainfrom
Conversation
Prepends https:// to server URLs when no scheme is provided and strips trailing slashes, improving developer experience for SDK initialization.
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.
Summary
Adds server URL normalization so users can pass schemeless URLs (e.g.,
"mycompany-be.glean.com") asserver_urlwhen constructing the SDK client. This is part of promotingserver_urlas the primary configuration option, replacinginstancein all documentation and examples.Python-specific implementation
Uses Speakeasy's SDKInit hook mechanism (
src/glean/api_client/_hooks/server_url_normalizer.py). The hook receives the raw server URL string during SDK initialization and normalizes it before it's used for requests. This is the standard approach — the Python SDK passes raw strings to the SDKInit hook (unlike TypeScript which passes parsed URL objects).The hook is registered in
registration.pyas the first hook to run during initialization.Normalization rules
https://http://preserved (for localhost/dev)https://preservedUser-facing API
Backwards compatibility
The
instanceparameter continues to work unchanged. No breaking changes.Test plan