Skip to content

feat: wrap exceptions thrown while authenticating #42

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

Merged
merged 1 commit into from
Apr 22, 2025

Conversation

jajeffries
Copy link
Contributor

This pull request includes improvements to error handling and test coverage in the netboxlabs/diode/sdk/client.py file and its associated tests. The most important changes include replacing a return statement with a raise statement for consistency, adding exception handling during authentication, and introducing a new test to validate error handling for connection exceptions.

Error handling improvements:

  • Replaced return RuntimeError with raise RuntimeError in the ingest method to ensure proper exception handling. (netboxlabs/diode/sdk/client.py, netboxlabs/diode/sdk/client.pyL240-R240)
  • Added a try-except block in the authenticate method to handle exceptions during the HTTP request and raise a DiodeConfigError with a meaningful message. (netboxlabs/diode/sdk/client.py, netboxlabs/diode/sdk/client.pyR292-R296)

Test coverage enhancements:

  • Added a new test, test_diode_authentication_request_exception, to verify that an exception during the HTTP request in the authenticate method raises a DiodeConfigError with the correct error message. (tests/test_client.py, tests/test_client.pyR616-R633)
  • Minor formatting adjustments in the test file, such as removing extra blank lines. (tests/test_client.py, tests/test_client.pyR591)

@mfiedorowicz mfiedorowicz changed the title wraps exceptions thrown while authenticating feat: wraps exceptions thrown while authenticating Apr 22, 2025
Copy link

github-actions bot commented Apr 22, 2025

Coverage

Coverage Report
FileStmtsMissCoverMissing
/opt/hostedtoolcache/Python/3.10.17/x64/lib/python3.10/site-packages/netboxlabs/diode/sdk
   client.py189498%75, 240, 275, 302
TOTAL221498% 

Tests Skipped Failures Errors Time
93 0 💤 0 ❌ 0 🔥 1.241s ⏱️

@mfiedorowicz mfiedorowicz changed the title feat: wraps exceptions thrown while authenticating feat: wrap exceptions thrown while authenticating Apr 22, 2025
@jajeffries jajeffries requested a review from Copilot April 22, 2025 15:36
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves error handling in the authentication process and enhances test coverage in the client module.

  • Replaces an incorrect return statement with raise for proper exception propagation.
  • Adds try-except handling in the authenticate method to raise a DiodeConfigError on failure.
  • Introduces a new test to validate exception handling during authentication requests.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
netboxlabs/diode/sdk/client.py Updates exception handling in both ingest and authenticate methods.
tests/test_client.py Adds a new test for request exceptions and includes minor formatting adjustments.

Copy link
Contributor

@leoparente leoparente left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@mfiedorowicz mfiedorowicz left a comment

Choose a reason for hiding this comment

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

👍

@jajeffries jajeffries merged commit 6c374d1 into update_datamodel Apr 22, 2025
3 checks passed
@jajeffries jajeffries deleted the wrap_auth_exception branch April 22, 2025 19:22
Copy link

🎉 This PR is included in version 1.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants