Fixed python & feature test failures caused by Werkzeug 3.1.7 rejecting empty Host header in CSRF token generation.#9791
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Walkthrough
Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@web/regression/python_test_utils/csrf_test_client.py`:
- Around line 97-98: Replace the hardcoded 'localhost' used for the 'HTTP_HOST'
header in the environ dictionary with a value derived from the Flask app config
(e.g. app.config.get('SERVER_NAME')): locate the environ/extra_environ
construction in csrf_test_client.py where 'HTTP_HOST' is set, compute host =
(app.config.get('SERVER_NAME') or 'localhost') and, if SERVER_NAME includes a
port, preserve it (split by ':' if present), then set 'HTTP_HOST' to that
derived host so tests respect configured SERVER_NAME and avoid cookie/domain
mismatches.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 51b9fee7-3317-4be9-8df2-cc577a59db8c
📒 Files selected for processing (1)
web/regression/python_test_utils/csrf_test_client.py
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@web/regression/python_test_utils/csrf_test_client.py`:
- Around line 97-98: The code accesses current_app.config before an application
context exists; replace current_app with the test client instance's application
config (use self.app.config) when building the environ dict so HTTP_HOST is
derived from self.app.config["SERVER_NAME"] or "localhost" instead of
current_app.config; update the environ entry that sets 'HTTP_HOST' accordingly
(look for the mapping containing 'wsgi.url_scheme' and 'HTTP_HOST') to avoid
RuntimeError during CSRF generation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d17f3e94-8b98-494e-acac-2c5c236b70f8
📒 Files selected for processing (1)
web/regression/python_test_utils/csrf_test_client.py
…ng empty Host header in CSRF token generation.
Co-authored-by: Khushboo Vashi <khushboo.vashi@gmail.com>
Summary by CodeRabbit