-
Notifications
You must be signed in to change notification settings - Fork 23
Fix wasm gated features in bitwarden-vault crate #543
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
Conversation
Several tests reference fields and methods only available with the wasm feature. Gate these code sections with #[cfg(feature = "wasm")] to allow tests to compile without the wasm feature. This fixes cargo test --package bitwarden-vault which previously failed due to feature resolution differences between workspace and package-specific testing.
Move imports only used in wasm-gated code behind #[cfg(feature = "wasm")] to eliminate unused import warnings when compiling without the wasm feature.
|
Claude finished @shane-melton's task —— View job Code Review CompleteSummary of ChangesThis PR adds proper feature gating for wasm-specific code in the
Files modified:
Critical IssuesNone identified. The changes are correct and complete. Suggested ImprovementsConsider adding a CI check for feature-gated compilationTo prevent similar issues in the future, consider adding a CI job that tests compilation without optional features: - name: Test without optional features
run: cargo test --package bitwarden-vault --no-default-featuresThis would catch feature gating issues early in development. Good Practices Observed
Detailed AnalysisFeature Gating PatternThe PR correctly applies the Struct field definition (attachment.rs:60-61): #[cfg(feature = "wasm")]
pub decrypted_key: Option<String>,Test field initialization (all test files): #[cfg(feature = "wasm")]
decrypted_key: None,This is the correct approach for conditional compilation in Rust. Import Gating (cipher_client/mod.rs)The changes properly separate imports by feature: use bitwarden_crypto::IdentifyKey;
#[cfg(feature = "wasm")]
use bitwarden_crypto::{CompositeEncryptable, SymmetricCryptoKey};This is more maintainable than: use bitwarden_crypto::{IdentifyKey, CompositeEncryptable, SymmetricCryptoKey};Because Test Function Gating (cipher_client/mod.rs:538-539)The #[tokio::test]
#[cfg(feature = "wasm")]This test uses Coverage VerificationI verified that all 8 instances of
Architecture CompliancePer the CLAUDE.md guidelines, this PR correctly handles feature-gated code without introducing business logic changes. The changes are purely compilation fixes that don't affect runtime behavior when the wasm feature is enabled. Action Items for AuthorNone - this PR is ready to merge. The implementation is correct, complete, and follows Rust best practices for conditional compilation. |
|
Great job! No new security vulnerabilities introduced in this pull request |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #543 +/- ##
=======================================
Coverage 78.70% 78.70%
=======================================
Files 296 296
Lines 30500 30507 +7
=======================================
+ Hits 24005 24012 +7
Misses 6495 6495 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…atures in bitwarden-vault crate (bitwarden/sdk-internal#543)

🎟️ Tracking
N/A
📔 Objective
Several tests referenced fields and methods only available with the
wasmfeature. Gate these code sections with#[cfg(feature = "wasm")]to allow tests to compile without thewasmfeature.This fixes
cargo test --package bitwarden-vaultwhich previously failed due to feature resolution differences between workspace and package-specific testing.⏰ Reminders before review
team
🦮 Reviewer guidelines
:+1:) or similar for great changes:memo:) or ℹ️ (:information_source:) for notes or general info:question:) for questions:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmedissue and could potentially benefit from discussion
:art:) for suggestions / improvements:x:) or:warning:) for more significant problems or concerns needing attention:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt:pick:) for minor or nitpick changes