Replace deprecated datetime.utcnow() with timezone-aware datetime.now(timezone.utc) - #251
Open
msarg44 wants to merge 1 commit into
Open
Conversation
…(timezone.utc) datetime.utcnow() is deprecated since Python 3.12 and returns naive datetimes. Replaced with datetime.now(timezone.utc) which returns timezone-aware datetimes, consistent with the scanner/engine.py convention used throughout the rest of the codebase.
Member
|
@msarg44 - Thanks for your contribution. CI seems to be failing, kindly recheck and provide the necessary fixes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces three instances of
datetime.datetime.utcnow()insentinel/ingest.pywithdatetime.now(timezone.utc).Why
datetime.utcnow()is deprecated since Python 3.12 and returns naive datetime objects, which can cause subtle timezone-related bugs in log ingestion pipelines where consistent UTC timestamps are important.What changed
import datetime→from datetime import datetime, timezonedatetime.datetime.utcnow()calls replaced withdatetime.now(timezone.utc)+ "Z"suffix on the isoformat line (now handled by timezone-aware datetime output)This brings
sentinel/ingest.pyin line with the rest of the codebase —scanner/engine.pyalready usesdatetime.now(timezone.utc)and imports fromdatetimewithtimezone.