bito-code-review[bot] commented on code in PR #38490:
URL: https://github.com/apache/superset/pull/38490#discussion_r2900325931
##########
superset/databases/schemas.py:
##########
@@ -277,6 +277,29 @@ def extra_validator(value: str) -> str:
)
]
)
+
+ metadata_cache_timeout = extra_.get("metadata_cache_timeout") or {}
+ if not isinstance(metadata_cache_timeout, dict):
+ raise ValidationError(
+ [
+ _(
+ "The metadata_cache_timeout must be a mapping from "
+ "string keys to non-negative integer values."
+ )
+ ]
+ )
+ for key in ("schema_cache_timeout", "table_cache_timeout"):
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Validation Logic Bug</b></div>
<div id="fix">
The current validation allows falsy non-dict values like 0 for
metadata_cache_timeout to pass without error, defaulting to {}. This should
raise a ValidationError for any non-dict value when the key is present, as
invalid input should be rejected.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
````suggestion
metadata_cache_timeout = extra_.get("metadata_cache_timeout")
if metadata_cache_timeout is not None:
if not isinstance(metadata_cache_timeout, dict):
raise ValidationError(
[
_(
"The metadata_cache_timeout must be a mapping
from "
"string keys to non-negative integer values."
)
]
)
else:
metadata_cache_timeout = {}
for key in ("schema_cache_timeout", "table_cache_timeout"):
````
</div>
</details>
</div>
<small><i>Code Review Run #35969a</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]