镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

fix(a2a): make list_tasks sorting and filtering safe across naive and aware datetimes - #8739

Open
梦想陆地的鱼 (heyseere) wants to merge 1 commit into
crewAIInc:mainfrom
heyseere:fix/a2a-list-tasks-timezone
Open

梦想陆地的鱼 (heyseere) wants to merge 1 commit into
crewAIInc:mainfrom
heyseere:fix/a2a-list-tasks-timezone

Conversation

@heyseere

@heyseere 梦想陆地的鱼 (heyseere) commented Oct 28, 2026 •

Copy link
Copy Markdown

Related issue

Fixes #8735

Summary

list_tasks raised TypeError: can't compare offset-naive and offset-aware datetimes when the task list mixed tasks carrying aware ISO timestamps with tasks without a timestamp (the sort key returned naive datetime.min), and when callers passed a naive status_timestamp_after. This PR normalizes status timestamps to aware UTC in a single helper used by both the sort key and the timestamp filter, and normalizes a naive cutoff at entry. Missing timestamps still sort as the oldest instant and are still exempt from the time filter — semantics unchanged, crash removed.

Verification

  • Tests added or updated for the changed behavior
  • Relevant tests and quality checks pass locally

lib/crewai/tests/a2a (104 passed): new tests cover mixed aware/missing-timestamp sorting, a naive cutoff, and an aware cutoff. The mixed-sort and naive-cutoff tests fail with TypeError on the old code. ruff check clean on changed files.

Disclosure: this PR was produced with AI assistance (ZCode agent) and human-reviewed — please apply the llm-generated label.

Additional context

None

From ZCode


Note

Low Risk
Targeted datetime normalization in a pure list utility with regression tests; no auth, persistence, or API contract changes beyond removing the crash.

Overview
Fixes TypeError when list_tasks compared offset-naive and offset-aware datetimes during sort or status_timestamp_after filtering.

A shared _parse_status_timestamp helper now parses ISO status strings (including Z), treats missing timestamps as oldest UTC, and upgrades naive values to UTC. list_tasks uses it for the sort key and cutoff filter, and coerces a naive status_timestamp_after to aware UTC at entry. Sort order and filter rules are unchanged.

Tests cover mixed missing/aware timestamp sorting, naive cutoffs, and aware time filtering.

Reviewed by Cursor Bugbot for commit c21e906. Bugbot is set up for automated code reviews on this repo. Configure here.

@strix-security

strix-security Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Strix Security Review

Warning

This pull request has 84 commits after the last Strix review (c7c8fc8). Strix has not reviewed these changes.
Automatic review on push is off for this repository. To review the latest changes, tag @strix-security in a comment, or turn on re-review on push.

✅ No open security findings.

PR summary: Adds a `_parse_status_timestamp` helper in the A2A task utilities that normalizes task status timestamps to aware UTC datetimes, and uses it for both the `list_tasks` timestamp filter and sort key, plus normalizing a naive `status_timestamp_after` cutoff. This removes the `TypeError` raised when tasks mixed aware timestamps with missing ones, and adds tests for the mixed, naive-cutoff, and aware-cutoff cases.

Review summary

This PR fixes a crash in the A2A list_tasks helper: a new _parse_status_timestamp normalizes every stored status timestamp to an aware UTC datetime (missing values becoming the oldest instant, naive values assumed UTC), and a naive status_timestamp_after cutoff is converted at entry, so sorting and filtering no longer raise TypeError on mixed naive/aware values. Security review found no vulnerability: the patch parses exactly the same strings with the same datetime.fromisoformat call as the pre-image (only adding non-raising tzinfo handling), removes exception surface rather than adding it, keeps context_id/status scoping untouched, and does not widen who can reach or see a task — the filter is a caller-side narrowing predicate, not an authorization decision, and ordering semantics are unchanged. The new tests only exercise the corrected comparison behavior.

Review 1 on this PR · c7c8fc8 · requested Oct 28 16:07 UTC when the PR was opened


Reviewed by Strix
Re-run review · Configure security review settings

@heyseere
梦想陆地的鱼 (heyseere) force-pushed the fix/a2a-list-tasks-timezone branch 2 times, most recently from 2f3babb to faf2a21 Compare October 29, 2026 15:42
@heyseere

Copy link
Copy Markdown
Author

Friendly ping for a review when you have a moment. All bot checks are green and the PR is mergeable; happy to adjust anything.

@heyseere
梦想陆地的鱼 (heyseere) force-pushed the fix/a2a-list-tasks-timezone branch 5 times, most recently from 3b6ce0c to e5231fc Compare November 8, 2026 06:49

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] a2a.utils.task.list_tasks raises TypeError when task timestamps mix aware and missing values

1 participant