abderbejaoui commented on code in PR #38490:
URL: https://github.com/apache/superset/pull/38490#discussion_r3531487859
##########
superset/databases/schemas.py:
##########
@@ -906,7 +939,10 @@ def fix_schemas_allowed_for_csv_upload( # pylint:
disable=invalid-name
metadata_params = fields.Dict(keys=fields.Str(), values=fields.Raw())
engine_params = fields.Dict(keys=fields.Str(), values=fields.Raw())
- metadata_cache_timeout = fields.Dict(keys=fields.Str(),
values=fields.Integer())
+ metadata_cache_timeout = fields.Dict(
+ keys=fields.Str(),
+ values=fields.Integer(validate=Range(min=0)),
+ )
Review Comment:
Resolved in `19b675f5e1`. The API validator now only validates
`metadata_cache_timeout` when the key is **present**, and requires a mapping —
so an explicit `null` is rejected, matching `ImportV1DatabaseExtraSchema`
(`fields.Dict` with no `allow_none`). An **absent** key still means "unset"
(valid), so no legitimate flow regresses — the UI only ever sends integers or
omits the key.
I also closed the symmetric nested case: `{"metadata_cache_timeout":
{"schema_cache_timeout": null}}` is now rejected too, matching import's inner
`fields.Integer`, which prevents an `enabled=True`/`timeout=None` state in the
model accessors. Tests cover top-level null, nested null (all three keys),
absent-key, and empty-dict.
Note: I aligned toward the "disallow null everywhere" option. The other
option (allow + normalize null) would actually crash
`Database.metadata_cache_timeout`, since it returns
`get_extra().get("metadata_cache_timeout", {})` — which yields `None` for an
explicit null, and `schema_cache_enabled` then does `"…" in None`. Resolving.
--
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]