bito-code-review[bot] commented on code in PR #40695:
URL: https://github.com/apache/superset/pull/40695#discussion_r3385294154
##########
superset/initialization/__init__.py:
##########
@@ -764,6 +764,23 @@ def cleanup_analytics_memory(response: Response) ->
Response:
gc.collect()
return response
+ @self.superset_app.before_request
+ def enforce_session_validity() -> Any:
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Incorrect return type for before_request hook</b></div>
<div id="fix">
Change the return type of `enforce_session_validity` to `->
Optional[Response]` and add `Optional` to the `from typing import` line to
match the callee's signature.
</div>
</div>
<small><i>Code Review Run #a1913b</i></small>
</div><div>
<div id="suggestion">
<div id="issue"><b>CWE-1024: Weak Type Validation</b></div>
<div id="fix">
The `before_request` handler `enforce_session_validity()` is annotated `->
Any` but the function it calls returns `Optional[Response]`. Flask
`before_request` handlers must return `None` to continue processing or a
`Response` to short-circuit. The incorrect `Any` annotation hides this contract
and may cause type-checking tools to miss related issues. (See also:
[CWE-1024](https://cwe.mitre.org/data/definitions/1024.html))
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
```
--- superset/initialization/__init__.py
+++ superset/initialization/__init__.py
@@ -765,7 +765,7 @@
return response
@self.superset_app.before_request
- def enforce_session_validity() -> Any:
+ def enforce_session_validity() -> Optional[Response]:
"""Force logout of sessions invalidated by a per-user epoch."""
from superset.security.session_invalidation import (
enforce_session_validity as _enforce,
```
</div>
</details>
</div>
<small><i>Code Review Run #02e482</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
##########
superset/migrations/versions/2026-06-02_10-00_f7a1c93e0b21_add_sessions_invalidated_at.py:
##########
@@ -0,0 +1,177 @@
+# Licensed to the Apache Software Foundation (ASF) under one
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Invalid Python module name</b></div>
<div id="fix">
The module name contains hyphens and a timestamp which violates PEP 8 naming
conventions. Consider renaming to a valid Python identifier.
</div>
</div>
<small><i>Code Review Run #02e482</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
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]