Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"None is not a valid Unit" in metrics.list.query(fields="entityType") #90

Closed
vduseev opened this issue Sep 10, 2024 · 0 comments
Closed
Labels
bug Something isn't working

Comments

@vduseev
Copy link
Collaborator

vduseev commented Sep 10, 2024

Describe the bug
If there is not unit field in the raw reply from the https://{your-environment-id}.live.dynatrace.com/api/v2/metrics API, the client doesn't handle it properly.

self.unit: Optional[Unit] = Unit(raw_element.get("unit"))

The Unit enum doesn't have any value for None, obviously.

To Reproduce
Steps to reproduce the behavior:

  • Make a call with fields specified: client.metrics.list.query(page_size=500, fields="entityType")

Solution:

Most likely, this needs to be rewritten to

self.unit: Optional[Unit] = Unit(raw_element.get("unit")) if raw_element.get("unit") else None

Currently, you can go around that by specifying unit as a field:

client.metrics.list.query(page_size=500, fields="+entityType,+unit")
@vduseev vduseev added the bug Something isn't working label Sep 10, 2024
@vduseev vduseev changed the title "None is not a valid Unit" in metrics.list.query() "None is not a valid Unit" in metrics.list.query(fields="entityType") Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant