Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(uploader): TypeError between offset-native and offset-aware datetimes#1082

Open
mango-cube wants to merge 1 commit into
microsoftgraph:main from
mango-cube:bugfix/large-file-upload-typeerror
Open

fix(uploader): TypeError between offset-native and offset-aware datetimes #1082
mango-cube wants to merge 1 commit into
microsoftgraph:main from
mango-cube:bugfix/large-file-upload-typeerror

Conversation

@mango-cube

@mango-cube mango-cube commented May 25, 2026
edited
Loading

Copy link
Copy Markdown

The error:

(.venv) C:\DeveloperFiles\Repos\reporting\bitbucket-reporter>python test.py
Traceback (most recent call last):
 File "C:\DeveloperFiles\Repos\reporting\bitbucket-reporter\test.py", line 21, in <module>
 asyncio.run(uploader.upload_large_file(file_to_upload='mango_test.txt', destination_path="root:/Reports/mango.txt:"))
 File "C:\Users\mango\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 190, in run
 return runner.run(main)
 ^^^^^^^^^^^^^^^^
 File "C:\Users\mango\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run
 return self._loop.run_until_complete(task)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "C:\Users\mango\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 654, in run_until_complete
 return future.result()
 ^^^^^^^^^^^^^^^
 File "C:\DeveloperFiles\Repos\reporting\bitbucket-reporter\sharepoint_uploader.py", line 110, in upload_large_file
 upload_result = await task.upload(progress_callback)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "c:\DeveloperFiles\Repos\reporting\bitbucket-reporter\.venv\Lib\site-packages\msgraph_core\tasks\large_file_upload.py", line 91, in upload
 if self.upload_session_expired(self.upload_session):
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "c:\DeveloperFiles\Repos\reporting\bitbucket-reporter\.venv\Lib\site-packages\msgraph_core\tasks\large_file_upload.py", line 81, in upload_session_expired
 interval = now - then
 ~~~~^~~~~~
TypeError: can't subtract offset-naive and offset-aware datetimes

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a TypeError in LargeFileUploadTask.upload_session_expired caused by subtracting offset-aware and offset-naive datetime values when validating whether an upload session has expired.

Changes:

  • Forces expiration_date_time datetimes to be treated as UTC to avoid naive/aware subtraction errors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 75 to 80
if isinstance(expiry, str):
then = datetime.strptime(expiry, "%Y-%m-%dT%H:%M:%S")
elif isinstance(expiry, datetime):
then = expiry
then = expiry.replace(tzinfo=timezone.utc)
else:
raise ValueError("Expiry is not a string or datetime")
Comment on lines +74 to +78
@@ -75,7 +75,7 @@ def upload_session_expired(self, upload_session: Optional[Parsable] = None) -> b
if isinstance(expiry, str):
then = datetime.strptime(expiry, "%Y-%m-%dT%H:%M:%S")
elif isinstance(expiry, datetime):
then = expiry
then = expiry.replace(tzinfo=timezone.utc)
@mango-cube mango-cube force-pushed the bugfix/large-file-upload-typeerror branch from 6a15626 to 4e04a12 Compare June 1, 2026 04:40

sonarqubecloud Bot commented Jun 1, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot Copilot left review comments

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /