DataDog / datadog-api-client-python

Python client for the Datadog API

Home Page:https://datadoghq.dev/datadog-api-client-python/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Type error when getting a dashboard

larryenvacances opened this issue · comments

Describe the bug
When trying to retrieve a dashboard by using the call dashboards_api.get_dashboard(dashboard.get("id")), I get an error saying datadog_api_client.v1.exceptions.ApiTypeError: Invalid type for variable 'x'. Required value type is int and passed type was float at ['received_data']['widgets'][15]['layout']['x']

To Reproduce
Steps to reproduce the behavior:

  1. Have a dashboard that has and X value that is a float and not an int
  2. Call get_dashboard for said dashboard
  3. See error

Expected behavior
The dashboard is returned with the float value for X

Environment and Versions (please complete the following information):

  • Windows 10
  • Python 3.10
  • api client v1

Hey there, reporting on the same issue, I am receiving a similar error with the monitor API. This seems to be specific to version 1.10.0.

A few observations:

  1. This triggered when I didn't provide pagination parameters for list_monitors
  2. When using get_monitor random ID's would not work, but some would. Seemed to be no specific pattern
  3. When giving an id_offset to list_monitors API call, it would also randomly error on specific ID's with a similar error above

If I roll back to 1.9: pip install datadog-api-client==1.9.0, this seems to fix the problem, so seems like a bug in the version 1.10 release.

Environment and Versions (please complete the following information):

Mac OS Monterey
Python 3.9
api client v1, v1.10

Hi,

Regarding the dashboard bug, it's a difference between the OpenAPI spec and old backend behavior. Obviously float X doesn't make sense, but it was still stored this way.

The monitor issue is completely different. It might be because of additional validation introduced in 1.10. Can you open a different issue? Thanks.

@therve thanks for the quick answer. do you have any hint on when that bug could be fixed or if there is a way we could mitigate on our side? I see the implementation isn't done in the v2 of the API yet.

I worked around the issue by using the http REST endpoint, but I would rather use the client so that I have the Model type of the dashboard returned to me.

A quick workaround would be to update the dashboard to only have have integers for x and y attributes.

Thanks for your contribution!

This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity. Thank you for participating in the Datadog open source community.

If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of this project.

  2. Comment that the issue is still reproducible and include updated details requested in the issue template.

Hey, Any plans to fix it? We hot-fixed it with local retyping float to int here https://github.com/DataDog/datadog-api-client-python/blob/master/src/datadog_api_client/v1/model/widget_layout.py#L85-L86
We want to fix corrupted (by manual interaction) dashboards automatically, but it is not doable as those manual changes break the loading via your module.

Thanks for your contribution!

This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity. Thank you for participating in the Datadog open source community.

If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of this project.

  2. Comment that the issue is still reproducible and include updated details requested in the issue template.

This is still an issue with the latest version 2.5.0, any plan on fixing this issue soon?

Is it happening on a recent dashboard? Otherwise just editing the dashboard and saving it should fix it. Please contact support so that we can see the problematic dashboard. Thanks.

Is it happening on a recent dashboard? Otherwise just editing the dashboard and saving it should fix it. Please contact support so that we can see the problematic dashboard. Thanks.

@therve Thanks for the reply! It was probably old dashboards, the problem was some of the widgets have x or y coordinate as floats, I managed to fix it by manually editing those dashboards resizing those individual widgets which the new coordinates are integers, not the most efficient solution but it got the work done.

Thanks for your contribution!

This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity. Thank you for participating in the Datadog open source community.

If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of this project.

  2. Comment that the issue is still reproducible and include updated details requested in the issue template.

We see this when using dashboards where we've edited the location of the widgets. It's possible that I could resolve it by editing every widget, but simply editing the console and saving it doesn't cause the widgets to snap to integer locations.

Would you consider a PR to accept floats like this?