Skip to content

Fix timezone issue for ingestion - #647

Open
FlorianBracq wants to merge 2 commits into
Azure:masterfrom
FlorianBracq:issue/fix-timezone-aware-datetimes
Open

FlorianBracq wants to merge 2 commits into
Azure:masterfrom
FlorianBracq:issue/fix-timezone-aware-datetimes

Conversation

@FlorianBracq

@FlorianBracq FlorianBracq commented Aug 20, 2026 •

Copy link
Copy Markdown

When using pyhon >= 3.12, DeprecationWarning are visible with messages such as:

datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
self._ingest_client_resources_last_update = datetime.utcnow()

Fixed

Replace datetime.utcnow() with datetime.now(tz=dt.timezone.utc)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Comparing the naive cached timestamp with a timezone-aware timestamp raises a TypeError on the second resource lookup, breaking even the first file or stream ingestion.

1 open issue
What changed in this PR

This PR updates the ingestion SDK’s timestamp handling to use timezone-aware UTC and address Python 3.12+ datetime.utcnow() deprecation warnings.

Changes:

  • Uses timezone-aware UTC for blob ingestion message creation timestamps.
  • Updates resource refresh comparisons and authorization-cache timestamps to use timezone-aware UTC.
File Description
azure-kusto-ingest/​azure/​kusto/​ingest/​ingestion_blob_info.py Adds UTC timezone information to ingestion message creation timestamps.
azure-kusto-ingest/​azure/​kusto/​ingest/​_resource_manager.py Updates refresh comparisons and authorization-cache timestamp handling.

Review effort: Max

@aasavbadera
Aasav Badera (aasavbadera) force-pushed the issue/fix-timezone-aware-datetimes branch from b9cc656 to 3fd5c48 Compare November 20, 2026 08:17
Keep resource cache writes and comparisons in aware UTC. Cover successive resource lookups and cache-expiry boundaries, verify UTC ingestion message serialization, and format the PR changes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6f4a536a-7f7a-4d39-b60e-96db0cb49c1c

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants