Skip to content

Test Result StartedAt Time gets changed during update_results_v2 #26

Description

@ericthemantis

The test result started_at timestamp is shifted back by the amount of the server timezone offset from UTC during the update_results_v2 API call.

You can see this by printing out the "test_result" object before and after the update_results_v2 API call in systemlink-server-examples/python/testmonitor/results.py

# Update the top-level test result's status based on the most severe child step's status.
display(test_result)
update_result_request = UpdateTestResultsRequest(results=[test_result], determine_status_from_steps=True)
response = await results_api.update_results_v2(update_result_request)
test_result = response.results[0]
display(test_result)

Output (properties abridged):

{'id': '84875ab5-d9b2-45ad-8e7b-9dfc7596d6a4',
 'started_at': datetime.datetime(2026, 5, 4, 17, 37, 6, 451284, tzinfo=tzutc()),
 'status': {'status_name': None, 'status_type': 'RUNNING'},
 'total_time_in_seconds': 0.0,
 'updated_at': datetime.datetime(2026, 5, 4, 17, 42, 6, 513275, tzinfo=tzutc())}

{'id': '84875ab5-d9b2-45ad-8e7b-9dfc7596d6a4',
 'started_at': datetime.datetime(2026, 5, 4, 10, 37, 6, 451284, tzinfo=tzutc()),
 'status': {'status_name': None, 'status_type': 'FAILED'},
 'total_time_in_seconds': 55.36366307250671,
 'updated_at': datetime.datetime(2026, 5, 4, 17, 42, 10, 604546, tzinfo=tzutc())}

This is due to a bug (unfiled) in the generated code in the generated python api, where a datetime object is not properly converted to an ISO-formatted string from the SystemLink REST API's.

Workaround:
Add the following line to convert the datetime object to a formatted string before calling update_results_v2

# Update the top-level test result's status based on the most severe child step's status.
test_result.started_at = (test_result.started_at).strftime("%Y-%m-%dT%H:%M:%S.%fZ") # New line to force properly formatted string
update_result_request = UpdateTestResultsRequest(results=[test_result], determine_status_from_steps=True)
response = await results_api.update_results_v2(update_result_request)
test_result = response.results[0]

Note: a formatted string should be used for the started_at property when creating a result, if a started_at time is explicitly set (a value of None sets the started_at as the current time)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions