growthbook-python
growthbook-python copied to clipboard
Fix 403 error in load_features() by adding proper User-Agent header
Summary
- Fixed 403 error occurring in
load_features()method on self-hosted GrowthBook instances - Added proper User-Agent header to HTTP requests made by the Python SDK
- Headers now include
GrowthBook-Python-SDK/{version}format
Problem
The Python SDK was failing with 403 errors when calling load_features() because urllib3.PoolManager() sends minimal
headers by default. Some servers (particularly self-hosted GrowthBook instances with WAF/nginx protection) block
requests without proper User-Agent headers.
Solution
Modified the _get() method in FeatureRepository class to include a proper User-Agent header for all HTTP requests.
Testing
- [x] MyPy type checking: No new type errors introduced
- [x] Test suite: All existing tests pass, no functionality broken
- [x] Flake8 linting: No new linting violations
- [x] Manual testing: Confirmed
load_features()now works on self-hosted instances - [x] Feature evaluation and experiment tracking functioning properly
Impact
- Resolves load_features() failures on self-hosted instances
- Maintains backward compatibility
- Improves SDK reliability across different server configurations
- No breaking changes to existing functionality