Skip to content

ctx.execute_batch() throws TypeError: can't compare offset-naive and offset-aware datetimes #967

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
matschundbrei opened this issue May 20, 2025 · 1 comment
Labels

Comments

@matschundbrei
Copy link

matschundbrei commented May 20, 2025

After upgrading via pip from 2.6.1 to 2.6.2 we receive the error from the title (details below) on the start of

ctx = ClientContext(url).with_access_token(spTokenService.getAccessTokenResponse)
[...]
ctx.execute_batch()
self.ctx.execute_batch()
    ~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/site-packages/office365/sharepoint/client_context.py", line 200, in execute_batch
    batch_request.execute_query(qry)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
  File "/usr/local/lib/python3.13/site-packages/office365/runtime/client_request.py", line 36, in execute_query
    request = self.build_request(query)
  File "/usr/local/lib/python3.13/site-packages/office365/runtime/odata/v3/batch_request.py", line 32, in build_request
    request.data = self._prepare_payload(query)
                   ~~~~~~~~~~~~~~~~~~~~~^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/office365/runtime/odata/v3/batch_request.py", line 77, in _prepare_payload
    request = qry.build_request()
  File "/usr/local/lib/python3.13/site-packages/office365/runtime/queries/client_query.py", line 35, in build_request
    return self.context.build_request(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/local/lib/python3.13/site-packages/office365/runtime/client_runtime_context.py", line 40, in build_request
    self.pending_request().beforeExecute.notify(request)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/office365/runtime/types/event_handler.py", line 41, in notify
    listener(*args, **kwargs)
    ~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/office3[65](https://code.stroeer.de/bi/s4r-bice-sharepoint-s3-sync/-/jobs/1135972#L65)/sharepoint/client_context.py", line 272, in _authenticate_request
    self.authentication_context.authenticate_request(request)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/office365/runtime/auth/authentication_context.py", line 275, in authenticate_request
    self._authenticate(request)
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/office365/runtime/auth/authentication_context.py", line 186, in _authenticate
    if self._cached_token is None or request_time > self._token_expires:
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: can't compare offset-naive and offset-aware datetimes

Note: we're pulling the module via pip inside a docker-image FROM python:3-alpine

downgrading back to 2.6.1 fixes the issue.

@vgrem vgrem added the bug label May 20, 2025
@vgrem
Copy link
Owner

vgrem commented May 20, 2025

Greetings!

Thank you for catching and reporting this issue. It looks like this PR is addressing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants