You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There appears to be a bug in the GitLab adapter at shared/torngit/gitlab.py, specifically in the get_commit method (and perhaps other methods and functions that consume timestamps from the GitLab API).
GitLab's EE/CE (i.e. self hosted) API documentation explicitly shows that timestamps include timezone offsets (e.g. "2021-09-20T09:06:12.300+03:00"): https://docs.gitlab.com/ee/api/commits.html
Codecov seems to ignore these offsets and treat the timestamps as UTC time. This leads to incorrect timestamps being stored and displayed by codecov, with the error being equal to the timezone offset of the original timestamp.
The issue impacts commit ordering and any features that rely on accurate commit timestamps. It also causes strange behaviour in the UI, for example if the UTC offset in the timestamp for the latest commit was +8 hours, the codecov UI will display "Last updated: In about 8 hours".
A local test patch confirms the issue can be fixed by properly handling the timezone conversion:
---shared/torngit/gitlab.py2024-10-0117:45:38.000000000+0000+++shared/torngit/gitlab.py2024-12-0102:54:56.222429098+0000@@ -1122,12+1122,24 @@name=authors[0]["name"]break+# GitLab returns timestamps with timezone offsets (e.g. "2021-09-20T09:06:12.300+03:00")+# These need to be converted to UTC ISO 8601 format for consistency+fromdatetimeimportdatetime+importpytz+# Parse the datetime string to a datetime object+local_dt=datetime.fromisoformat(res["committed_date"])
+# Convert the local datetime to UTC+utc_dt=local_dt.astimezone(pytz.utc)
+# Format the UTC datetime to ISO 8601 string+utc_iso8601=utc_dt.isoformat().replace('+00:00', 'Z')
+log.info(f'PATCH: The timestamp for commit {commit} from GitLab was {res["committed_date"]}, but we will convert it to {utc_iso8601}')
+returndict(
author=dict(id=_id, username=username, email=email, name=name),
message=res["message"],
parents=res["parent_ids"],
commitid=commit,
-timestamp=res["committed_date"],
+timestamp=utc_iso8601,
)
asyncdefget_pull_request_commits(self, pullid, token=None):
Environment
I have GitLab community edition and codecov self-hosted images version 24.10.1 running on a kubernetes cluster.
To Reproduce
Use a GitLab project that is configured with CI/CD pipelines to push test coverage to codecov.
Make a commit using git CLI command on a system whose timezone is not UTC.
Push that commit to the GitLab EE or CE repository so the pipeline runs.
Query the commit information through GitLab's API directly to see the timezone offset in the timestamp: curl "https://<your_gitlab_host>/api/v4/projects/<project_id>/repository/commits/<commit_sha>"
Compare this with how the timestamp appears in CodeCov.
Notice the timestamp is off by the amount of the timezone offset.
Expected behaviour
The system should:
Parse the GitLab timestamp string, preserving the timezone information
Convert the datetime to UTC
Store/return the UTC timestamp in ISO 8601 format
Display consistent timestamps regardless of the original commit's timezone
Additional context
I found this issue with my own GitLab community edition self hosted instance, but I assume it also affects GitLab.com.
The text was updated successfully, but these errors were encountered:
Describe the bug
There appears to be a bug in the GitLab adapter at
shared/torngit/gitlab.py
, specifically in theget_commit
method (and perhaps other methods and functions that consume timestamps from the GitLab API).GitLab's EE/CE (i.e. self hosted) API documentation explicitly shows that timestamps include timezone offsets (e.g.
"2021-09-20T09:06:12.300+03:00"
): https://docs.gitlab.com/ee/api/commits.htmlCodecov seems to ignore these offsets and treat the timestamps as UTC time. This leads to incorrect timestamps being stored and displayed by codecov, with the error being equal to the timezone offset of the original timestamp.
The issue impacts commit ordering and any features that rely on accurate commit timestamps. It also causes strange behaviour in the UI, for example if the UTC offset in the timestamp for the latest commit was +8 hours, the codecov UI will display "Last updated: In about 8 hours".
A local test patch confirms the issue can be fixed by properly handling the timezone conversion:
Environment
I have GitLab community edition and codecov self-hosted images version 24.10.1 running on a kubernetes cluster.
To Reproduce
git
CLI command on a system whose timezone is not UTC.curl "https://<your_gitlab_host>/api/v4/projects/<project_id>/repository/commits/<commit_sha>"
Expected behaviour
The system should:
Additional context
I found this issue with my own GitLab community edition self hosted instance, but I assume it also affects GitLab.com.
The text was updated successfully, but these errors were encountered: