MagicStack / MagicStack/asyncpg

OverflowError: date value out of range

Open
#412 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
8.1k
Forks
468
PR merge metrics
No merged PRs in 30d

Description

* **asyncpg version**: 0.18.3
* **PostgreSQL version**: 10.7
* **Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
the issue with a local PostgreSQL install?**: Yes
* **Python version**: 3.7
* **Platform**: Mac OS
* **Do you use pgbouncer?**: No
* **Did you install asyncpg with pip?**: Yes
* **If you built asyncpg locally, which version of Cython did you use?**:
* **Can the issue be reproduced under both asyncio and
[uvloop](https://github.com/magicstack/uvloop)?**:

asyncpg is failing to parse timestamp

code:
```
import asyncio
import asyncpg

async def run():
conn = await asyncpg.connect(user='secure', password='secure',
database='secure',
host='secure.com', port=15432, timeout=600)

values = await conn.fetch('''SELECT _ts FROM Events''')
print(values)
await conn.close()

loop = asyncio.get_event_loop()
loop.run_until_complete(run())
```

```
Timestamp format: 2019-01-01T08:42:25.921Z
```

```
Traceback (most recent call last):
File "/scratch_65.py", line 21, in
loop.run_until_complete(run())
File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
return future.result()
File "/scratch_65.py", line 15, in run
values = await conn.fetch('''SELECT _ts FROM Events''')
File "/lib/python3.7/site-packages/asyncpg/connection.py", line 421, in fetch
return await self._execute(query, args, 0, timeout)
File "/lib/python3.7/site-packages/asyncpg/connection.py", line 1414, in _execute
query, args, limit, timeout, return_status=return_status)
File "/lib/python3.7/site-packages/asyncpg/connection.py", line 1422, in __execute
return await self._do_execute(query, executor, timeout)
File "/lib/python3.7/site-packages/asyncpg/connection.py", line 1444, in _do_execute
result = await executor(stmt, None)
File "asyncpg/protocol/protocol.pyx", line 196, in bind_execute
File "asyncpg/protocol/coreproto.pyx", line 65, in asyncpg.protocol.protocol.CoreProtocol._read_server_messages
File "asyncpg/protocol/coreproto.pyx", line 202, in asyncpg.protocol.protocol.CoreProtocol._process__bind_execute
File "asyncpg/protocol/coreproto.pyx", line 498, in asyncpg.protocol.protocol.CoreProtocol._parse_data_msgs
File "asyncpg/protocol/protocol.pyx", line 754, in asyncpg.protocol.protocol.BaseProtocol._decode_row
File "asyncpg/protocol/prepared_stmt.pyx", line 282, in asyncpg.protocol.protocol.PreparedStatementState._decode_row
File "asyncpg/protocol/codecs/base.pyx", line 288, in asyncpg.protocol.protocol.Codec.decode
File "asyncpg/protocol/codecs/base.pyx", line 195, in asyncpg.protocol.protocol.Codec.decode_scalar
File "asyncpg/pgproto/./codecs/datetime.pyx", line 252, in asyncpg.pgproto.pgproto.timestamptz_decode
OverflowError: date value out of range

```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with asyncpg/pgproto/./codecs/datetime.pyx at timestamptz_decode, then reproduce the failure using the provided Python query against PostgreSQL. Trace how the reported timestamp is decoded and add coverage for this case if the repository has a relevant test location. Done means the query returns the timestamp without OverflowError.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, python
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.