fix: make X-Glean hook resilient to SDK regeneration#107
Merged
chris-freeman-glean merged 1 commit intomainfrom Feb 3, 2026
Merged
fix: make X-Glean hook resilient to SDK regeneration#107chris-freeman-glean merged 1 commit intomainfrom
chris-freeman-glean merged 1 commit intomainfrom
Conversation
Use getattr() with defaults instead of direct attribute access for exclude_deprecated_after and include_experimental config fields. This fixes mypy errors that occur after Speakeasy regenerates sdkconfiguration.py, which removes the custom fields added in PR #106. The hook now gracefully handles missing attributes while still supporting environment variables (which take precedence anyway). Co-Authored-By: Claude Opus 4.5 <[email protected]>
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
getattr()with defaults instead of direct attribute access forexclude_deprecated_afterandinclude_experimentalconfig fieldssdkconfiguration.pyBackground
PR #106 added custom fields to
sdkconfiguration.pyfor X-Glean header support. However, Speakeasy regenerates this file daily, removing the custom fields. The hook (x_glean.py) survives regeneration but then references non-existent attributes, causing mypy failures:This has been breaking the Generate CI workflow since Jan 27th.
Solution
Replace direct attribute access with
getattr()calls that returnNonewhen the attribute doesn't exist:Verification
speakeasy runwhich regeneratedsdkconfiguration.pywithout custom attributesTest plan
poetry run python -m mypy src/glean/api_clientpoetry run pytest tests/test_x_glean_hook.py -v🤖 Generated with Claude Code