Change server_certificate to PathBuf#22
Conversation
Change server_certificate to PathBuf since not all valid paths can be represented as strings (e.g., paths with non-UTF-8 characters).
|
@microsoft-github-policy-service agree |
|
@olback can you open a issue describing what would happen if this change is not made with some more details? |
|
@saurabh500 Sure, see #23 |
|
@olback we are still setting up infrastructure to allow PR builds. In the meanwhile I will leave a few comments. |
|
Please run Since we haven't released mssql-tds breaking change is OK, but since all consumers of mssql-tds are in the repo itself (for now), it would be good to make sure that all consumers compile |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR updates certificate path handling to use PathBuf instead of String, enabling support for non-UTF-8 filesystem paths (particularly relevant on Unix-like platforms).
Changes:
- Replace
server_certificate: Option<String>withOption<PathBuf>across core types and tests. - Update certificate loading/validation helpers to accept
&Pathand storePathBufin error variants. - Adjust Rust and Python binding tests/call sites to pass
PathBuf/&Pathand log paths viadisplay().
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| mssql-tds/tests/test_mock_server_tls.rs | Updates tests to construct server_certificate as a PathBuf. |
| mssql-tds/tests/test_mock_server.rs | Updates multiple tests to pass PathBuf for server_certificate. |
| mssql-tds/src/error/mod.rs | Changes certificate-related error variants to store PathBuf paths. |
| mssql-tds/src/core.rs | Updates public EncryptionOptions.server_certificate type to Option<PathBuf>. |
| mssql-tds/src/connection/transport/ssl_handler.rs | Adjusts logging and tests for PathBuf-based certificate pinning. |
| mssql-tds/src/connection/transport/certificate_validator.rs | Refactors certificate loading/validation APIs to accept &Path and updates tests accordingly. |
| mssql-py-core/src/connection.rs | Updates PyO3 extraction to parse server_certificate as PathBuf. |
Comments suppressed due to low confidence (1)
mssql-tds/src/connection/transport/certificate_validator.rs:1
- This repeats
path.to_path_buf()several times when constructing errors. Consider creating a single ownedPathBufupfront (e.g.,let path_buf = path.to_path_buf();) and reusing/cloning it for error variants, which reduces duplication and makes future edits less error-prone.
// Copyright (c) Microsoft Corporation.
| trust_server_certificate: true, // This should be ignored | ||
| host_name_in_cert: None, | ||
| server_certificate: Some(cert_path.to_str().unwrap().to_string()), | ||
| server_certificate: Some(cert_path.clone()), |
There was a problem hiding this comment.
PR metadata indicates cargo btest was not run. Since this PR changes a public type (EncryptionOptions.server_certificate) and associated validation code, it would be important to run the full test suite (cargo btest) and update the checklist before merging to avoid regressions.
Of course, I totally missed the python crate. Should be all good now though. @saurabh500 |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Change server_certificate to PathBuf since not all valid paths can be represented as strings (e.g., paths with non-UTF-8 characters).
Description
Related Issues
Checklist
cargo bfmtpassescargo bclippypassescargo btestpasses