Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="astrbot/core/tools/cron_tools.py" line_range="315" />
<code_context>
+ same_session = _extract_job_session(job) == current_umo
+ can_delete = _job_belongs_to_current_sender(
+ job, current_umo, current_sender_id
+ ) or (same_session and _is_group_admin(context.context.event))
+ if not can_delete:
if same_session and not _extract_job_sender(job):
</code_context>
<issue_to_address>
**Deleted tasks still execute**
When a scheduled run's row lookup overlaps an admin deletion and returns the row before the deletion commits, `CronJobManager._run_job` adds its task to `_running_tasks` only after awaiting the row lookup, while `delete_job` removes the schedule and snapshots that set before deleting the row. A run that fetched the row but has not registered yet escapes cancellation and executes after the admin receives a deletion success.
Coordinate run registration and deletion (for example, with a per-job lock or deletion marker) so a run cannot start after deletion has begun.
</issue_to_address>
### Comment 2
<location path="astrbot/core/tools/cron_tools.py" line_range="47-56" />
<code_context>
)
+def _is_group_admin(event: Any) -> bool:
+ """Check whether the event sender is an AstrBot admin acting in a group chat.
+
+ Args:
+ event: The current message event.
+
+ Returns:
+ True when the sender is an AstrBot admin and the event is a group message.
+ """
+ return event.get_message_type() == MessageType.GROUP_MESSAGE and event.is_admin()
+
+
</code_context>
<issue_to_address>
**Unneeded permission helper extraction**
When the helper is added to the existing tool implementation, `_is_group_admin` adds a helper to an existing function for a one-line predicate used at only two sites, without the repeated-logic or significant readability/length justification required by the rule.
Inline the predicate at its two call sites and remove `_is_group_admin`.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 1 finding to address first, and the change grants group-chat admins authority to delete other members’ scheduled tasks, including same-group tasks without a recorded creator; a mistaken deletion can cancel future runs and is not undone by reverting the code. This is a permission-boundary decision, so an overly broad grant may not produce an error that signals the policy is wrong.
Blocking findings: astrbot/core/tools/cron_tools.py:315
Soulter
approved these changes
Oct 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #10782
Group task visibility should be shared by everyone in the current group, while changes remain subject to ownership checks. Previously,
future_taskrequired both the session and sender to match for every operation, so members could not list each other's tasks and AstrBot administrators could not remove them from chat.This PR lets all group members list every task in the current group conversation, with
creator=<sender_id>on each row (unknownfor tasks without a recorded creator). Regular members can edit and delete only their own tasks. AstrBot administrators can additionally delete other members' tasks, including same-group WebUI or legacy tasks with no recorded chat creator. Editing remains limited to the creator.Administrator privileges refer to AstrBot's configured administrators (
admins_id), not platform group administrators. All access remains scoped to the current conversation. Private chats retain both session and sender isolation.Permissions in the current group
Implementation
future_taskfiltering and tool guidance for shared group visibility while preserving edit and delete authorization.No database schema, Dashboard API, dependency, or WebUI navigation/layout changes are included.
Validation
python -m pytest tests/unit/test_cron_tools.py tests/unit/test_cron_edit_validation.py tests/unit/test_cron_manager.py tests/unit/test_cron_service.py -q: 92 passed.tests/unit/test_cron_events.py: 105 passed, 1 failed. The failure is the existing log-capture assertion intest_missing_platform_does_not_record_send: the warning is printed butcaplog.textis empty. The identical failure was reproduced in the untouched original checkout.ruff format .andruff check .: passed.git diff --check: passed.