aminghadersohi opened a new pull request, #36195:
URL: https://github.com/apache/superset/pull/36195

   ### SUMMARY
   
   Fixes the `AUTH_RATE_LIMITED` configuration to work correctly when set to 
`True`. Previously, enabling this setting would cause the application to fail 
during startup.
   
   **Before this fix:**
   When `AUTH_RATE_LIMITED = True` is set in `superset_config.py`, the 
application fails to start with:
   ```
   AttributeError: 'NoneType' object has no attribute '__module__'
   ```
   
   **After this fix:**
   The application starts successfully with rate limiting properly applied to 
the auth view.
   
   **Root cause:**
   Flask-AppBuilder's `register_views()` method tries to apply rate limiting to 
`self.auth_view.blueprint`, but in certain initialization contexts (e.g., MCP 
service's flask_singleton), the blueprint is `None`, causing the error.
   
   **Solution:**
   1. Apply rate limiting directly in Superset's `register_views()` method 
after the auth view is created
   2. Prevent the parent's `register_views()` from attempting to re-apply rate 
limiting by temporarily disabling `AUTH_RATE_LIMITED` during the `super()` call
   
   This ensures rate limiting works correctly regardless of how many Flask app 
instances are created.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A - Backend fix
   
   ### TESTING INSTRUCTIONS
   
   **Before fix (reproduces error):**
   1. Set `AUTH_RATE_LIMITED = True` in `superset_config.py`
   2. Run: `PYTHONPATH=. superset run -p 8088`
   3. Observe: Application fails with AttributeError
   
   **After fix (works correctly):**
   1. Set `AUTH_RATE_LIMITED = True` in `superset_config.py`
   2. Run: `PYTHONPATH=. superset run -p 8088`
   3. Observe: Application starts successfully
   4. Verify rate limiting is working by making multiple POST requests to 
`/login/` rapidly
   
   **MCP Service test:**
   1. Set `AUTH_RATE_LIMITED = True` and `MCP_AUTH_ENABLED = True` in 
`superset_config.py`
   2. Run: `PYTHONPATH=. superset mcp run --port 5008`
   3. Observe: MCP service starts successfully
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue:
   - [ ] Required feature flags: None
   - [ ] Changes UI: No
   - [ ] Includes DB Migration: No
   - [ ] Introduces new feature or API: No
   - [ ] Removes existing feature or API: No


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to