Skip to content

Consolidate and harden NI-TLS create_grpc_channel error descriptions - #12

Merged
alexdubois-ni merged 2 commits into
mainfrom
users/adubois/hardenErrorsAndMakeThemConsistent
Aug 24, 2026
Merged

alexdubois-ni merged 2 commits into
mainfrom
users/adubois/hardenErrorsAndMakeThemConsistent

Conversation

@alexdubois-ni

@alexdubois-ni alexdubois-ni commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

What does this Pull Request accomplish?

Consolidate and harden NI-TLS create_grpc_channel error descriptions

Why should this Pull Request be merged?

As of today, I added quite a bit of fud and inactionable user information to our error descriptions. Furthermore, there is a lot of error scenario detection logic surrounding this as well that can be simplified by using a consolidated error messaging. In the end, the ONLY actionable user scenario is that a TLS configuration error occurred and that they need to check Hardware Manager that they did setup correctly. We should reflect this in the error description.

Last but not least, let's also create a base error class that user's of nitlsconfig can utilize to catch all error types from nitlsconfig and inherit from that separately between the Cli related errors and grpc_channel configuration related errors. This way, user's have a more flexible and streamlined error handling capabilities. Make minor improvements to the cli errors to ensure they all inherit from this base.

Lastly, also make an improvement to one of the most prominent errors which is: What to do when nitlsconfig is not even installed!

Note: We do not care about backwards compatibility yet since this package is not truly "released" yet in any form. It is all in alpha development.

What testing has been done?

Updated unit-tests accordingly.

@ni-github-admins

ni-github-admins commented Aug 24, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Consolidates NI-TLS channel errors and introduces a shared package exception hierarchy.

Changes:

  • Adds common CLI and TLS exception base classes.
  • Simplifies TLS validation and standardizes error guidance.
  • Updates server-mode tests for fail-closed behavior.

Reviewed changes

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

Show a summary per file
File Description
src/nitlsconfig/errors.py Defines the exception hierarchy.
src/nitlsconfig/cli.py Imports centralized CLI exceptions.
src/nitlsconfig/grpc_channel.py Consolidates TLS validation and messages.
src/nitlsconfig/__init__.py Exports the new exception API.
tests/unit/test_grpc_channel.py Updates TLS mode and validation tests.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/nitlsconfig/__init__.py
Comment thread src/nitlsconfig/errors.py
@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown

Test Results

 12 files  ± 0   12 suites  ±0   15s ⏱️ ±0s
 66 tests  -  2   66 ✅  -  2  0 💤 ±0  0 ❌ ±0 
792 runs   - 24  792 ✅  - 24  0 💤 ±0  0 ❌ ±0 

Results for commit a7db719. ± Comparison against base commit 6baa5fb.

This pull request removes 6 and adds 4 tests. Note that renamed tests count towards both.
tests.unit.test_grpc_channel ‑ test_invalid_configuration_raises[empty_certificate_path]
tests.unit.test_grpc_channel ‑ test_invalid_configuration_raises[non_file_certificate_scheme]
tests.unit.test_grpc_channel ‑ test_invalid_configuration_raises[trust_always_unsupported]
tests.unit.test_grpc_channel ‑ test_invalid_configuration_raises[unknown_server_mode]
tests.unit.test_grpc_channel ‑ test_invalid_configuration_raises[unknown_trust_scheme]
tests.unit.test_grpc_channel ‑ test_skip_hostname_validation_matches_trusted_certificates
tests.unit.test_grpc_channel ‑ test_non_disabled_server_modes_match_trusted_certificates[SkipHostnameValidation]
tests.unit.test_grpc_channel ‑ test_non_disabled_server_modes_match_trusted_certificates[TrustAlways]
tests.unit.test_grpc_channel ‑ test_non_disabled_server_modes_match_trusted_certificates[Unknown]
tests.unit.test_nitlsconfig ‑ test_command_timeout_is_reported_as_a_package_error

♻️ This comment has been updated with latest results.

…ror posture of all errors underlying a single base

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

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

@alexdubois-ni
alexdubois-ni requested a review from ckoellin August 24, 2026 19:23
@alexdubois-ni
alexdubois-ni merged commit b329f64 into main Aug 24, 2026
31 checks passed
@alexdubois-ni
alexdubois-ni deleted the users/adubois/hardenErrorsAndMakeThemConsistent branch August 24, 2026 21:17
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.

4 participants