Skip to content

Commit bd14dc7

Browse files
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 <noreply@anthropic.com>
1 parent 0ca4291 commit bd14dc7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/glean/api_client/_hooks/x_glean.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ def before_request(
4949
# Get deprecated value - env var takes precedence
5050
deprecated_value = _get_first_value(
5151
os.environ.get("X_GLEAN_EXCLUDE_DEPRECATED_AFTER"),
52-
hook_ctx.config.exclude_deprecated_after,
52+
getattr(hook_ctx.config, "exclude_deprecated_after", None),
5353
)
5454

5555
# Get experimental value - env var takes precedence
5656
config_experimental = (
57-
"true" if hook_ctx.config.include_experimental is True else None
57+
"true" if getattr(hook_ctx.config, "include_experimental", None) is True else None
5858
)
5959
experimental_value = _get_first_value(
6060
os.environ.get("X_GLEAN_INCLUDE_EXPERIMENTAL"),

0 commit comments

Comments
 (0)