Aware datetime serialization changes scheduled-message instants by ignoring UTC offsets
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 35/100
Research direction
Read the handwritten twilio.base.serialize.iso8601_datetime serializer and the public-client tests for scheduled messages. Reproduce the two timezone-offset cases through the mocked HTTP transport, then check that naive datetimes, date-only values, preformatted strings, and the unset sentinel retain their existing behavior. Done means aware datetimes serialize to the correct UTC instant; the issue reports that pull request #981 is already open.
Written by the indexing model from the issue text.
Description
Issue
The handwritten twilio.base.serialize.iso8601_datetime formats timezone-aware datetimes with strftime("%Y-%m-%dT%H:%M:%SZ") without converting their timezone to UTC. This changes the represented instant when the datetime has a nonzero UTC offset.
Through the public client (mocked HTTP transport), Client(...).messages.create(..., schedule_type="fixed", send_at=datetime(2030, 1, 2, 1, 30, tzinfo=timezone(timedelta(hours=5, minutes=30)))) currently sends SendAt=2030-01-02T01:30:00Z. It should send 2030-01-01T20:00:00Z. Negative offsets can similarly cross the next day. Twilio's scheduling timestamp documentation calls for a UTC ISO8601 timestamp.
Proposed fix and validation
Convert aware datetimes to UTC before adding the Z suffix. Keep naive datetimes, date-only values, preformatted strings and the unset sentinel's existing behavior. This touches the handwritten shared serializer, not generated REST methods.
Two public-client timezone cases fail before the fix; four controls pass. Afterward the full required make test workflow passes:647 tests, both Flake8 runs, Autoflake and Black (797 files). Tested Python3.12; no real messages or live Twilio requests, and no full Python matrix. AI-assisted contribution, maintainer review pending.
- Dominant language
- Python
- Stars
- 2.1k
- Forks
- 821
- Avg merge
- 9h 33m
- Merged PRs (30d)
- 3
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from twilio/twilio-python
-
Docs: "Handling Exceptions" should mention that network errors are not `TwilioRestException`Possibly taken @henricop claimed this 13 days ago. Open
Difficulty 1/5 1-3 hours Newbie friendliness 90/100
twilio/twilio-python#986 · 1 comment ·
Maintainers usually reply within 1 day
-
Clearer diagnostic when an API Key SID is passed without `account_sid`Possibly taken @saryeljaramany claimed this 5 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
twilio/twilio-python#985 · 1 comment ·
Maintainers usually reply within 1 day
-
TokenPagination.next_page_async() makes a sync request and fails with an async http clientPossibly taken @sebxt claimed this 31 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
twilio/twilio-python#976 ·
Maintainers usually reply within 1 day
-
AsyncTwilioHttpClient does not JSON-serialize request bodies for application/json endpoints (sync client does) → 400 on JSON-body v2 endpointsPossibly taken @Steve0x2a claimed this 77 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
twilio/twilio-python#932 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
twilio/twilio-python#930 ·
Maintainers usually reply within 1 day
All issues in twilio/twilio-python
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
Maintainers usually reply within 1 day
-
area:cli area:security enhancement priority:medium size:small
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
RonaldHensbergen/composable-data-stack#1338 ·
Maintainers usually reply within 1 day
-
area:stdlib effort:S impact:med platform:linux type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
automated endpoint-dead needs-curation
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
almanac-data/climate-almanac#139 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
UKGovernmentBEIS/inspect_ai#6695 · 1 comment ·
Maintainers usually reply within 1 day