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: url attribute type validation #672

Merged
merged 4 commits into from
Sep 24, 2024
Merged

Conversation

VitalyChait
Copy link
Contributor

@VitalyChait VitalyChait commented Sep 17, 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'

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 17, 2024

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

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.47%. Comparing base (70ce8cb) to head (9da8314).
Report is 1 commits behind head on master.

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

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #672   +/-   ##
=======================================
  Coverage   90.47%   90.47%           
=======================================
  Files          40       40           
  Lines        3526     3528    +2     
=======================================
+ Hits         3190     3192    +2     
  Misses        336      336           
Flag Coverage Δ
90.47% <100.00%> (+0.29%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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, thank you for your PR! 👍

Could you please add tests to cover your changes? This will ensure that your additions work as intended and maintain the integrity of the project.

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.

LGTM 🚀

@bednar bednar added this to the 1.47.0 milestone Sep 24, 2024
@bednar bednar merged commit 3d70dbd into influxdata:master Sep 24, 2024
15 checks passed
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