codeant-ai-for-open-source[bot] commented on code in PR #43307:
URL: https://github.com/apache/superset/pull/43307#discussion_r3809880166
##########
superset/tasks/cron_util.py:
##########
@@ -19,12 +19,57 @@
from collections.abc import Iterator
from datetime import datetime, timedelta
+from cron_descriptor import ExpressionDescriptor, get_description
from croniter import croniter, CroniterBadDateError
from flask import current_app
from pytz import timezone as pytz_timezone, UnknownTimeZoneError
logger = logging.getLogger(__name__)
+# Field values that place no restriction on a cron field. ``?`` is the Quartz
+# spelling of "no specific value" and is accepted by ``cron_descriptor``.
+UNRESTRICTED_CRON_FIELDS = {"*", "?"}
+
+
+def get_cron_description(cron: str) -> str:
+ """
+ Build a human readable description of a cron expression.
+
+ ``cron_descriptor`` renders a restricted day-of-month next to a restricted
+ day-of-week as a single comma separated clause -- ``0 9 7-11 * 2`` becomes
+ "At 09:00 AM, on day 7 through 11 of the month, only on Tuesday" -- which
+ reads as an intersection. POSIX cron, and therefore ``croniter`` (which
+ picks the fire times in :func:`cron_schedule_window`), takes the *union* of
+ the two fields when both are restricted: the schedule fires on every
+ matching day of the month as well as on every matching day of the week.
+ Join the two clauses with "or" so the description matches when the job
+ really runs.
+ """
+ description = get_description(cron)
+
+ fields = cron.split()
+ if len(fields) != 5:
+ return description
Review Comment:
**Suggestion:** Expressions are only corrected when they contain exactly
five fields. However, `validate_crontab` and `cron_schedule_window` both
delegate to `croniter`, which accepts six- and seven-field expressions,
including schedules with restricted day-of-month and day-of-week fields. Those
schedules bypass the OR replacement and continue to display the original
intersection-like description. Either support all cron formats accepted by the
scheduler or explicitly reject non-five-field expressions during validation.
[api mismatch]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ⚠️ API-accepted extended cron schedules show misleading descriptions.
- ⚠️ Report list and detail views disagree with scheduler fire times.
- ⚠️ Users may misinterpret alert or report execution dates.
```
</details>
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/tasks/cron_util.py
**Line:** 50:52
**Comment:**
*Api Mismatch: Expressions are only corrected when they contain exactly
five fields. However, `validate_crontab` and `cron_schedule_window` both
delegate to `croniter`, which accepts six- and seven-field expressions,
including schedules with restricted day-of-month and day-of-week fields. Those
schedules bypass the OR replacement and continue to display the original
intersection-like description. Either support all cron formats accepted by the
scheduler or explicitly reject non-five-field expressions during validation.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43307&comment_hash=075c88b7f6e04e5e02a1effef334b8df0b091078e19165ac32a07c1fd5158313&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43307&comment_hash=075c88b7f6e04e5e02a1effef334b8df0b091078e19165ac32a07c1fd5158313&reaction=dislike'>👎</a>
--
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]