Closed The-Compiler closed 4 months ago
@The-Compiler I have basically the same setup as you and can reproduce the problem with
paperless = get_paperless()
async with paperless as p:
document = await paperless.documents(844)
success = await document.update()
JsonResponseWithError: Paperless: created - Datetime has wrong format. Use one of these formats instead: YYYY-MM-DDThh:mm[:ss[.uuuuuu]][+HH:MM|-HH:MM|Z].
A nasty workaround is to modify created..
paperless = get_paperless()
async with paperless as p:
document = await paperless.documents(844)
document.created = datetime.datetime(10,10,10).isoformat()
success = await document.update()
Hi folks, thank you for throwing in that issue. That'll gonna be fixed soon :)
Thank you! Gonna release the bugfix today.
First of all, thanks for this project! I'm quite impressed that you went for asyncio for your first Python project - despite using Python for some 13 years, this was the first time I used asyncio for something non-trivial, and (even being no stranger to async concepts in general, thanks to PyQt): Phew!
If you're curious, here is what I did before running into what I believe to be a bug (described below):
With Python 3.11.7, pypaperless 3.0.1 and Paperless-ngx 2.5.4 configured with
PAPERLESS_TIME_ZONE=Europe/Zurich
, any patch operation fails:results in:
because what's being sent to the API is:
but that makes no sense (both
+01:00
but alsoZ
, which stands for a zero offset from UTC).This seems to be due to the
result = result.rstrip("Z") + "Z"
here:https://github.com/tb1337/paperless-api/blob/6a819f0b6e16324ee0ec5a0f85c43ebda5057fd9/pypaperless/models/utils/__init__.py#L41-L46
added in:
87
and I can't quite wrap my head around it. The only place where it would make a difference is when
datetime.datetime.isoformat()
would have multipleZ
suffixes (or+00:00Z
), which I don't think ever happens? If there is aZ
(or+00:00
) already, this is a no-op - but crucially, if there is a different timezone, this adds aZ
, causing things to explode.Simply removing that line (and the
if
) makes things work just fine for me - but it's unclear to me if there's a good reason why it's there which I'm missing.