From bd14dc7f252b1df329468ac2fa5a904ad3ba3a29 Mon Sep 17 00:00:00 2001 From: Chris Freeman Date: Tue, 3 Feb 2026 10:08:28 -0700 Subject: [PATCH] fix: make X-Glean hook resilient to SDK regeneration 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 --- src/glean/api_client/_hooks/x_glean.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/glean/api_client/_hooks/x_glean.py b/src/glean/api_client/_hooks/x_glean.py index 74adba54..6aa88575 100644 --- a/src/glean/api_client/_hooks/x_glean.py +++ b/src/glean/api_client/_hooks/x_glean.py @@ -49,12 +49,12 @@ def before_request( # Get deprecated value - env var takes precedence deprecated_value = _get_first_value( os.environ.get("X_GLEAN_EXCLUDE_DEPRECATED_AFTER"), - hook_ctx.config.exclude_deprecated_after, + getattr(hook_ctx.config, "exclude_deprecated_after", None), ) # Get experimental value - env var takes precedence config_experimental = ( - "true" if hook_ctx.config.include_experimental is True else None + "true" if getattr(hook_ctx.config, "include_experimental", None) is True else None ) experimental_value = _get_first_value( os.environ.get("X_GLEAN_INCLUDE_EXPERIMENTAL"),