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

fix: add url object type validation #670

Closed
wants to merge 6 commits into from
Closed

fix: add url object type validation #670

wants to merge 6 commits into from

Conversation

VitalyChait
Copy link
Contributor

@VitalyChait VitalyChait commented Sep 16, 2024

fix: added type validation to an attribute in client object

Proposed Changes

It is possible to pass "None" by mistake to the InfluxDBClient object.
I propose to do a quick sanity check on it.

Traceback example:
client_obj = InfluxDBClient(url=url, token=token, org=org)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "vitaly.chait/.local/lib/python3.12/site-packages/influxdb_client/client/influxdb_client.py", line 63, in init
super().init(url=url, token=token, debug=debug, timeout=timeout, enable_gzip=enable_gzip, org=org,
File "vitaly.chait/.local/lib/python3.12/site-packages/influxdb_client/client/_base.py", line 56, in init
if self.url.endswith("/"):
^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'endswith'
Exception ignored in: <function InfluxDBClient.del at 0x7ff5627789a0>
Traceback (most recent call last):
File "vitaly.chait/.local/lib/python3.12/site-packages/influxdb_client/client/influxdb_client.py", line 319, in del
if self.api_client:
^^^^^^^^^^^^^^^
AttributeError: 'InfluxDBClient' object has no attribute 'api_client'

Briefly describe your proposed changes:

Checklist

  • CHANGELOG.md updated
  • Rebased/mergeable
  • A test has been added if appropriate
  • pytest tests completes successfully
  • Commit messages are conventional
  • Sign CLA (if not already signed)

@codecov-commenter
Copy link

codecov-commenter commented Sep 16, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 90.44%. Comparing base (70ce8cb) to head (f4f3cec).

Files with missing lines Patch % Lines
influxdb_client/client/_base.py 50.00% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #670      +/-   ##
==========================================
- Coverage   90.47%   90.44%   -0.03%     
==========================================
  Files          40       40              
  Lines        3526     3528       +2     
==========================================
+ Hits         3190     3191       +1     
- Misses        336      337       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@bednar bednar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VitalyChait thanks for your PR 👍

Please satisfy our Checklist:

image

@VitalyChait VitalyChait changed the title Add url object type validation fix: add url object type validation Sep 17, 2024
@VitalyChait VitalyChait requested a review from bednar September 17, 2024 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants