Skip to content

Code crash while querying for notification endpoint #243

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

Closed
abhi1693 opened this issue May 4, 2021 · 9 comments · Fixed by #261
Closed

Code crash while querying for notification endpoint #243

abhi1693 opened this issue May 4, 2021 · 9 comments · Fixed by #261
Labels
bug Something isn't working
Milestone

Comments

@abhi1693
Copy link
Contributor

abhi1693 commented May 4, 2021

Steps to reproduce:
We are trying to fetch the notification endpoints. Here is the minimal code

client = InfluxDBClient.from_env_properties(enable_gzip=True)
org_id = "xxx"
api_client = client.api_client
notifications_service = NotificationEndpointsService(api_client=api_client)
endpoint_list = notifications_service.get_notification_endpoints(org_id=org_id)
print(endpoint_list.get())

I have masked the org_id. The underlying issue could be tied to an incorrect schema. Since there is little to no documentation on generating and verifying the code using the open API schema, I was unable to determine the root cause.

Expected behaviour:
The API should return the endpoint list.

Actual behaviour:

  File "/venv/lib/python3.8/site-packages/influxdb_client/service/notification_endpoints_service.py", line 378, in get_notification_endpoints
    (data) = self.get_notification_endpoints_with_http_info(org_id, **kwargs)  # noqa: E501
  File "/venv/lib/python3.8/site-packages/influxdb_client/service/notification_endpoints_service.py", line 458, in get_notification_endpoints_with_http_info
    return self.api_client.call_api(
  File "/venv/lib/python3.8/site-packages/influxdb_client/api_client.py", line 340, in call_api
    return self.__call_api(resource_path, method,
  File "/venv/lib/python3.8/site-packages/influxdb_client/api_client.py", line 182, in __call_api
    return_data = self.deserialize(response_data, response_type)
  File "/venv/lib/python3.8/site-packages/influxdb_client/api_client.py", line 254, in deserialize
    return self.__deserialize(data, response_type)
  File "/venv/lib/python3.8/site-packages/influxdb_client/api_client.py", line 293, in __deserialize
    return self.__deserialize_model(data, klass)
  File "/venv/lib/python3.8/site-packages/influxdb_client/api_client.py", line 642, in __deserialize_model
    kwargs[attr] = self.__deserialize(value, attr_type)
  File "/venv/lib/python3.8/site-packages/influxdb_client/api_client.py", line 270, in __deserialize
    return [self.__deserialize(sub_data, sub_kls)
  File "/venv/lib/python3.8/site-packages/influxdb_client/api_client.py", line 270, in <listcomp>
    return [self.__deserialize(sub_data, sub_kls)
  File "/venv/lib/python3.8/site-packages/influxdb_client/api_client.py", line 293, in __deserialize
    return self.__deserialize_model(data, klass)
  File "/venv/lib/python3.8/site-packages/influxdb_client/api_client.py", line 647, in __deserialize_model
    klass_name = instance.get_real_child_model(data)
  File "/venv/lib/python3.8/site-packages/influxdb_client/domain/notification_endpoint_discriminator.py", line 56, in get_real_child_model
    discriminator_key = self.attribute_map[self.discriminator]
KeyError: None

Specifications:

  • Client Version: 1.17.0
  • InfluxDB Version: 2.0.5
  • Platform: Ubuntu 20.04
@abhi1693
Copy link
Contributor Author

abhi1693 commented May 4, 2021

@bednar Can you please help?

@bednar
Copy link
Contributor

bednar commented May 5, 2021

Hi @abhi1693,

it looks like that a schema generated by the OpenAPI generator is not correct. We will take a look.

Regards

@abhi1693
Copy link
Contributor Author

abhi1693 commented May 6, 2021

@bednar Is there any ETA on this? Our complete development is on hold again

@bednar
Copy link
Contributor

bednar commented May 7, 2021

We don't have ETA, but Today I will start working on this. Can you describe your usecase, please? It will be useful for us to be sure that we are deliver correct solution for you.

@abhi1693
Copy link
Contributor Author

abhi1693 commented May 7, 2021 via email

@bednar bednar added the bug Something isn't working label May 7, 2021
@abhi1693
Copy link
Contributor Author

@bednar Any progress on this?

@abhi1693
Copy link
Contributor Author

@bednar We have a deadline on a project. Can you please give an ETA otherwise we will think of some other way to manage the notification stack?

@bednar
Copy link
Contributor

bednar commented May 17, 2021

Hi @abhi1693, sorry for late.

I don't have exact ETA for you, but today I've start working on this issue. As a workaround you can directly call InfluxDB API by something like this:

from influxdb_client import InfluxDBClient

url = "http://localhost:8086"
token = "my-token"
org_id = "my-org-id"

with InfluxDBClient(url=url, token=token, org=org_id) as client:
    query_params = [('orgID', org_id)]

    notificationEndpoints = client.api_client.call_api('/api/v2/notificationEndpoints',
                                                       'GET',
                                                       query_params=query_params,
                                                       response_type=object)[0]
    print(notificationEndpoints)

    notificationRules = client.api_client.call_api('/api/v2/notificationRules',
                                                   'GET',
                                                   query_params=query_params,
                                                   response_type=object)[0]
    print(notificationRules)

Regards

@bednar
Copy link
Contributor

bednar commented May 25, 2021

Hi @abhi1693,

there is an upcoming fix for Monitoring & Alerting API - #261. You can try the dev version by:

pip install git+https://github.com/influxdata/influxdb-client-python.git@feat/swagger-update

and there is also an corresponding example: https://github.com/influxdata/influxdb-client-python/blob/feat/swagger-update/examples/monitoring_and_alerting.py

Regards

@bednar bednar added this to the 1.18.0 milestone May 28, 2021
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

Successfully merging a pull request may close this issue.

2 participants