From 09740b204cd9195f893a471dabd70357f47884ea Mon Sep 17 00:00:00 2001 From: Jakub Bednar Date: Wed, 6 Apr 2022 07:51:52 +0200 Subject: [PATCH 1/2] chore: improve error message if there is no organization with required name --- influxdb_client/client/util/helpers.py | 9 +++++++-- tests/test_Helpers.py | 5 +++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/influxdb_client/client/util/helpers.py b/influxdb_client/client/util/helpers.py index 548486c0..e1fdce90 100644 --- a/influxdb_client/client/util/helpers.py +++ b/influxdb_client/client/util/helpers.py @@ -39,7 +39,12 @@ def get_org_query_param(org, client, required_id=False): "to determine their ID. Are you using token with sufficient permission?" raise InfluxDBError(response=None, message=message) return organizations[0].id - except ApiException: - return None + except ApiException as e: + if e.status == 404: + from influxdb_client.client.exceptions import InfluxDBError + message = f"The client cannot find organization with name: '{_org}' " \ + "to determine their ID." + raise InfluxDBError(response=None, message=message) + raise e return _org diff --git a/tests/test_Helpers.py b/tests/test_Helpers.py index 8cec768a..d06f9110 100644 --- a/tests/test_Helpers.py +++ b/tests/test_Helpers.py @@ -31,8 +31,9 @@ def test_required_id(self): self.assertEqual(self.my_organization.id, org) def test_required_id_not_exist(self): - org = get_org_query_param("not_exist_name", self.client, required_id=True) - self.assertIsNone(org) + with pytest.raises(InfluxDBError) as e: + get_org_query_param("not_exist_name", self.client, required_id=True) + assert "The client cannot find organization with name: 'not_exist_name' to determine their ID." in f"{e.value} " def test_both_none(self): self.client.close() From e330919c40c0ac5ee51c98fd473cb215f32181a4 Mon Sep 17 00:00:00 2001 From: Jakub Bednar Date: Wed, 6 Apr 2022 07:53:45 +0200 Subject: [PATCH 2/2] docs: update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index de1b6bdf..bf578852 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ ## 1.28.0 [unreleased] +### Bug Fixes +1. [#425](https://github.com/influxdata/influxdb-client-python/pull/425): Improve error message if there is no `organization` with required `name` + ## 1.27.0 [2022-03-18] ### Features pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy