Skip to content

Dynatrace API does not always return milliseconds #111

@fishi0x01

Description

@fishi0x01

Describe the bug
Dynatrace API does not return milliseconds if they are 000, e.g., 2025-01-18T21:35:03.000Z gets returned as 2025-01-18T21:35:03Z

That leads to the following error in the client API:

ValueError("time data '2025-01-18T21:35:03Z' does not match format '%Y-%m-%dT%H:%M:%S.%fZ'")

This might be an issue in the API itself, but for now we can mitigate it by accepting both ISO pattern (with and without ms).

We currently fix this behavior by monkey patching the iso parsing function app-sre/qontract-reconcile#4815

Proposing a fix here: #110

To Reproduce
This is hard to reproduce and we stumbled across it by chance.
Essentially you have a 1:1000 chance that you will create an API token at exactly 000ms.

Steps to reproduce the behavior:

  1. Create a token at exactly 000ms
  2. try to use tokens.list()
  3. see error

Expected behavior
Properly parse whatever is returned by the API

Screenshots
None

Desktop (please complete the following information):
Not relevant - this is a general bug in how the client parses the response

Smartphone (please complete the following information):
Not relevant - this is a general bug in how the client parses the response

Additional context
None

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions