From c195230e99e7ed2539e42c2a4791d079c39b2bc6 Mon Sep 17 00:00:00 2001 From: Vitaly Chait Date: Tue, 17 Sep 2024 12:10:10 +0300 Subject: [PATCH 1/4] fix: url attribute type validation --- influxdb_client/client/_base.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/influxdb_client/client/_base.py b/influxdb_client/client/_base.py index 8dcf75e9..d4f17901 100644 --- a/influxdb_client/client/_base.py +++ b/influxdb_client/client/_base.py @@ -53,6 +53,8 @@ def __init__(self, url, token, debug=None, timeout=10_000, enable_gzip=False, or self.default_tags = default_tags self.conf = _Configuration() + if not isinstance(self.url, str): + raise ValueError('"url" attribute is not str instance') if self.url.endswith("/"): self.conf.host = self.url[:-1] else: From 626cefc7ef32ea6fd2a1fd9c44127a689502402f Mon Sep 17 00:00:00 2001 From: Vitaly Chait Date: Tue, 17 Sep 2024 12:11:57 +0300 Subject: [PATCH 2/4] docs: Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ebaccef3..129100e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Bug Fixes 1. [#667](https://github.com/influxdata/influxdb-client-python/pull/667): Missing `py.typed` in distribution package +2. [#672](https://github.com/influxdata/influxdb-client-python/pull/672): Adding type validation to url attribute in client object ### Examples: 1. [#664](https://github.com/influxdata/influxdb-client-python/pull/664/): Multiprocessing example uses new source of data From dfec5c3821f467fd97598ac26be1f6ee60c6b0fc Mon Sep 17 00:00:00 2001 From: Vitaly Date: Fri, 20 Sep 2024 02:07:21 +0300 Subject: [PATCH 3/4] test: added test_url_attribute function --- tests/test_InfluxDBClient.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/test_InfluxDBClient.py b/tests/test_InfluxDBClient.py index 7fdf834f..228f391b 100644 --- a/tests/test_InfluxDBClient.py +++ b/tests/test_InfluxDBClient.py @@ -323,6 +323,35 @@ def test_version(self): version = self.client.version() self.assertTrue(len(version) > 0) + def test_url_attribute(self): + # Wrong URL attribute + wrong_types = [ + None, + True, False, + 123, 123.5, + dict({"url" : "http://localhost:8086"}), + list(["http://localhost:8086"]), + tuple(("http://localhost:8086")) + ] + correct_types = [ + "http://localhost:8086" + ] + for url_type in wrong_types: + try: + client_not_running = InfluxDBClient(url=url_type, token="my-token", debug=True) + status = True + except ValueError as e: + status = False + self.assertFalse(status) + for url_type in correct_types: + try: + client_not_running = InfluxDBClient(url=url_type, token="my-token", debug=True) + status = True + except ValueError as e: + status = False + self.assertTrue(status) + + def test_build(self): build = self.client.build() self.assertEqual('oss', build.lower()) From 9da8314b486d5478f1b78f87e82e1298761ae7c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Bedn=C3=A1=C5=99?= Date: Tue, 24 Sep 2024 14:14:28 +0200 Subject: [PATCH 4/4] docs: Update CHANGELOG.md --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 129100e7..6937e242 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,12 @@ ## 1.47.0 [unreleased] +### Bug Fixes +1. [#672](https://github.com/influxdata/influxdb-client-python/pull/672): Adding type validation to url attribute in client object + ## 1.46.0 [2024-09-13] ### Bug Fixes 1. [#667](https://github.com/influxdata/influxdb-client-python/pull/667): Missing `py.typed` in distribution package -2. [#672](https://github.com/influxdata/influxdb-client-python/pull/672): Adding type validation to url attribute in client object ### Examples: 1. [#664](https://github.com/influxdata/influxdb-client-python/pull/664/): Multiprocessing example uses new source of data 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