atlassian-api / atlassian-python-api

Atlassian Python REST API wrapper
https://atlassian-python-api.readthedocs.io
Apache License 2.0
1.29k stars 642 forks source link

Parsing date-time string for pipeline.completed_on failing due to strftime issue. #1372

Open CrispyCB opened 2 months ago

CrispyCB commented 2 months ago
Traceback (most recent call last):
  File "/opt/atlassian/pipelines/agent/build/pipelineAuditHandler.py", line 84, in <module>
    audit_repositories(selectquote, fintech_repo_list)
  File "/opt/atlassian/pipelines/agent/build/pipelineAuditHandler.py", line 61, in audit_repositories
Repository found: fintech-ui
    f"{nickname} ran a {state} pipeline against {pipeline.data['target']['ref_name']} in {repo.name} on {pipeline.completed_on}.\n"
  File "/usr/local/lib/python3.10/site-packages/atlassian/bitbucket/cloud/repositories/pipelines.py", line 139, in completed_on
    return self.get_time("completed_on")
  File "/usr/local/lib/python3.10/site-packages/atlassian/bitbucket/base.py", line 167, in get_time
    value = datetime.strptime(value_str, self.CONF_TIMEFORMAT)
  File "/usr/local/lib/python3.10/_strptime.py", line 568, in _strptime_datetime
    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
  File "/usr/local/lib/python3.10/_strptime.py", line 349, in _strptime
    raise ValueError("time data %r does not match format %r" %
ValueError: time data '2024-04-10T20:16:48.914706353Z' does not match format '%Y-%m-%dT%H:%M:%S.%f%z'

Attempting to parse pipeline.completed_on (or any date-time string, I assume) fails with the above error.

Steps to recreate:

  1. Get a single Atlassian pipeline run.
  2. Print its completed_on value.