mikebridge commented on code in PR #44514:
URL: https://github.com/apache/superset/pull/44514#discussion_r4097642397
##########
superset/versioning/utils.py:
##########
@@ -44,8 +49,25 @@ def capture_enabled() -> bool:
would let this gate pass while listeners stay detached, producing
exactly the untracked write it exists to prevent. Restart the process
(or re-run ``init_versioning()``) after changing the flag.
+
+ VERSIONING_CAPTURE_PREDICATE is a separate runtime decision, consulted by
+ the baseline/change listeners and CaptureUnitOfWork as well as restore.
+ The host owns tenant identity, bounded transaction memoization and expected
+ service-failure handling. Database/programming errors are not suppressed.
"""
- return bool(current_app.config.get("ENABLE_VERSIONING_CAPTURE", False))
+ if not current_app.config.get("ENABLE_VERSIONING_CAPTURE", False):
+ return False
+ predicate: Callable[[Session], bool] | None = current_app.config.get(
+ "VERSIONING_CAPTURE_PREDICATE"
+ )
+ if predicate is None:
+ return True
+ if session is None:
+ # Deferred because extensions configures the UnitOfWork at import time.
+ from superset.extensions import db # pylint:
disable=import-outside-toplevel
+
+ session = db.session()
Review Comment:
Addressed in d658013d57: restore validation now passes its scoped session
explicitly to the capture gate, with a regression test that fails if the
argument is removed.
##########
superset/config.py:
##########
@@ -1761,22 +1791,24 @@ def sync_theme_logo_href(
def _parse_version_history_retention_days() -> int:
"""Parse the retention window without making invalid input fatal."""
- value: str | None =
os.environ.get("SUPERSET_VERSION_HISTORY_RETENTION_DAYS")
+ value: str | None = os.environ.get("VERSION_HISTORY_RETENTION_DAYS")
if value is None:
return _DEFAULT_VERSION_HISTORY_RETENTION_DAYS
try:
- retention_days = int(value)
+ retention_days: int = int(value)
except ValueError:
logger.warning(
- "Invalid SUPERSET_VERSION_HISTORY_RETENTION_DAYS=%r; using %d",
+ "Invalid VERSION_HISTORY_RETENTION_DAYS=%r; using %d",
value,
_DEFAULT_VERSION_HISTORY_RETENTION_DAYS,
)
return _DEFAULT_VERSION_HISTORY_RETENTION_DAYS
+ if retention_days < -1:
+ logger.warning("Invalid negative VERSION_HISTORY_RETENTION_DAYS;
skipping")
+ return 0
Review Comment:
Addressed in d658013d57: invalid negative and other malformed runtime
retention values now defer cleanup instead of falling back to 30 days. The
supported -1 value still means immediate eligibility.
--
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]