You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/11/03 23:25:29 UTC
[GitHub] [superset] betodealmeida commented on a change in pull request #17338: fix: add fallback and validation for report and cron timezones
betodealmeida commented on a change in pull request #17338:
URL: https://github.com/apache/superset/pull/17338#discussion_r742420601
##########
File path: superset/tasks/cron_util.py
##########
@@ -28,8 +28,12 @@ def cron_schedule_window(cron: str, timezone: str) -> Iterator[datetime]:
window_size = app.config["ALERT_REPORTS_CRON_WINDOW_SIZE"]
# create a time-aware datetime in utc
time_now = datetime.now(tz=dt_timezone.utc)
- tz = pytz.timezone(timezone)
- utc = pytz.timezone("UTC")
+ try:
+ tz = pytz_timezone(timezone)
+ except UnknownTimeZoneError:
+ # fallback to default timezone
+ tz = pytz_timezone("UTC")
Review comment:
Maybe add a log here, saying that a report was saved with an invalid timezone?
##########
File path: superset/reports/schemas.py
##########
@@ -153,7 +154,11 @@ class ReportSchedulePostSchema(Schema):
allow_none=False,
required=True,
)
- timezone = fields.String(description=timezone_description, default="UTC")
+ timezone = fields.String(
+ description=timezone_description,
+ default="UTC",
+ validate=validate.OneOf(choices=tuple(all_timezones)),
Review comment:
Nice!
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org