[Bounty proposal] fix(messaging): coerce received_at timestamps to UTC and guard null media tuples ($50 proposed)
Summary
In ackend/utils/messaging/gateway.py, ackend/utils/messaging/album_turn.py, and ackend/utils/messaging/identity.py, inbound messaging queue workers and head-advancement checks crash with unhandled TypeError or ValueError when stored inbox payloads or identity records contain timezone-naive ISO-8601 strings, datetime objects, or explicit None media/ttachments fields:
- Unprotected subtraction before ry/finally settlement in Gateway._process (ackend/utils/messaging/gateway.py:200):
- Immediately after self.store.claim_next marks the inbox head 'running', _process evaluates (datetime.now(timezone.utc) - datetime.fromisoformat(payload['received_at'])).total_seconds() outside the ry ... except BaseException ... finally block.
- If payload['received_at'] is a timezone-naive ISO-8601 string or already a datetime object, datetime.fromisoformat(...) or the subtraction against datetime.now(timezone.utc) raises TypeError before self.store.settle(path) can run, leaving the claimed FIFO head wedged in 'running'.
- Naive
eceived_at and explicit None media/ttachments in inbox_message (ackend/utils/messaging/album_turn.py:19-24):
- inbox_message(payload) calls datetime.fromisoformat(payload['received_at']) directly without coercing naive timestamps to UTC or accepting datetime objects, causing ChannelMessage.post_init to raise ValueError('received_at must be timezone aware') on naive ISO strings or TypeError when eceived_at is already a datetime.
- payload.get('media', ()) and payload.get('attachments', ()) return None when the stored dict has {'media': None} or {'attachments': None}, raising TypeError: 'NoneType' object is not iterable.
- Mixed naive/aware/ISO comparison in dvances_inbound_head (ackend/utils/messaging/identity.py:11-19):
- dvances_inbound_head(message, prior) compares message.received_at > before and message.received_at < before directly, raising TypeError: can't compare offset-naive and offset-aware datetimes when prior.get('received_at') is deserialized as a naive datetime or ISO-8601 string.
Proposed Fix
- Add coerce_utc_datetime() in ackend/utils/messaging/identity.py and use it in dvances_inbound_head(), inbox_message(), and Gateway._process() / _process_claimed().
- Guard payload.get('media') or () and payload.get('attachments') or () in inbox_message(), and construct the wake-pending message via inbox_message(payload) in Gateway._process().
- Add unit tests in ackend/tests/unit/test_messaging_received_at_coercion.py.
Bounty settlement address (Base Mainnet USDC): 0xb9f3765aeb1974c27a193463f655a1a57b3aec94
Bounty Payout Coordinates
- PayPal:
[email protected] - Base Mainnet USDC:
0xb9f3765aeb1974c27a193463f655a1a57b3aec94
Fix submitted in #23172 (huynhnhatquandongnai-source:fix/messaging-received-at-utc-coercion).
Bounty settlement address (Base Mainnet USDC): 0xb9f3765aeb1974c27a193463f655a1a57b3aec94
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! 🙏
Fix submitted in PR #23846: https://github.com/BasedHardware/omi/pull/23846
Payout Address
- Wallet: 0xC345C07229307d4f1c7935aD2cAe48e390215808
- Network: Polygon / Base / Arbitrum / Stellar