Skip to content

[Bounty proposal] fix(processing-attention): coerce timestamps to UTC and guard null retry maps ($50 proposed) #23169

Closed as not planned

Description

Summary

In �ackend/database/processing_attention.py, attention-item duration calculation, retry-claim lease expiration checks, and retry-state inspection crash with unhandled TypeError or AttributeError when stored conversation or claim documents contain naive datetime / ISO-8601 string timestamps or explicit None
etry fields:

  1. Mixed naive/aware datetime subtraction in iming(row) (lines 29-33):
    • iming(row) computes (end - start).total_seconds() directly when isinstance(start, datetime) and isinstance(end, datetime).
    • When started_at/created_at and inished_at mix timezone-naive and timezone-aware datetime objects, (end - start) raises TypeError: can't subtract offset-naive and offset-aware datetimes inside create_in_transaction and pending_conversations.
    • When timestamps are stored as ISO-8601 strings, isinstance(..., datetime) evaluates to False, silently reporting duration_seconds: 0.
  2. Naive datetime / ISO-8601 string comparison in lease_live(operation, now) (lines 120-125):
    • lease_live(operation, now) compares expires > now where
      ow = now_utc() (UTC-aware).
    • If lease_expires_at or created_at is deserialized as a timezone-naive datetime, expires > now raises TypeError: can't compare offset-naive and offset-aware datetimes inside claim_in_transaction and owns_live_claim.
    • If lease_expires_at or created_at is an ISO-8601 string, isinstance(..., datetime) is False, causing lease_live to return False and allowing an active in-progress retry claim to be prematurely clobbered.
  3. Explicit None
    etry field in list_items (line 97) and claim_in_transaction (line 191)
    :
    • Both functions call item.get('retry', {}).get('state'). When item['retry'] is explicitly None ({'retry': None}), item.get('retry', {}) returns None and .get('state') raises AttributeError: 'NoneType' object has no attribute 'get'.

Proposed Fix

  • Add _coerce_utc_datetime() in �ackend/database/processing_attention.py to normalize naive datetime, aware datetime, and ISO-8601 strings to UTC-aware datetime in iming() and lease_live().
  • Guard item.get('retry') with isinstance(..., dict) and use .get() for operation fields in list_items() and claim_in_transaction().
  • Add unit tests in �ackend/tests/unit/test_processing_attention_timestamp_guards.py.

Bounty settlement address (Base Mainnet USDC): 0xb9f3765aeb1974c27a193463f655a1a57b3aec94

Bounty Payout Coordinates

  • PayPal: [email protected]
  • Base Mainnet USDC: 0xb9f3765aeb1974c27a193463f655a1a57b3aec94

Activity

  1. huynhnhatquandongnai-source commented on Oct 22, 2026

    @huynhnhatquandongnai-source
    Author

    Fix submitted in #23170 (huynhnhatquandongnai-source:fix/processing-attention-timestamp-guards).

    Bounty settlement address (Base Mainnet USDC): 0xb9f3765aeb1974c27a193463f655a1a57b3aec94

  2. moved this from Someday to In progress in omi TODO / bountieson Oct 22, 2026
  3. undivisible commented on Oct 22, 2026

    @undivisible
    Collaborator

    Thanks for putting this together. We aren't doing bounties at the moment, so we're closing the bounty proposal issues for now — thanks for the fix! 🙏

  4. moved this from In progress to In review in omi TODO / bountieson Oct 22, 2026
  5. moved this from In review to In progress in omi TODO / bountieson Oct 28, 2026
  6. Dimank92 commented on Oct 28, 2026

    @Dimank92
    Contributor

    Fix submitted in PR #23847: #23847

    Payout Address

    • Wallet: 0xC345C07229307d4f1c7935aD2cAe48e390215808
    • Network: Polygon / Base / Arbitrum / Stellar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions