Skip to content

Conversation

mzieniukbw
Copy link
Contributor

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-24051

📔 Objective

UserDecryption response model tagged with sdk-wasm in OpenApi generated schema.
This is easier than manually post-processing the generated json schema before generating Rust models.
See bitwarden/sdk-internal#376 for example usage.

📸 Screenshots

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation 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 confirmed issue 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

@mzieniukbw mzieniukbw requested review from a team as code owners August 7, 2025 15:07
@mzieniukbw mzieniukbw requested review from Thomas-Avery, enmande, a team and coroiu August 7, 2025 15:07
Copy link

sonarqubecloud bot commented Aug 7, 2025

Copy link

codecov bot commented Aug 7, 2025

Codecov Report

❌ Patch coverage is 38.88889% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.02%. Comparing base (1c2bccd) to head (aaa96c0).
⚠️ Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
src/SharedWeb/Swagger/EnumSchemaFilter.cs 0.00% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6171      +/-   ##
==========================================
+ Coverage   48.51%   49.02%   +0.50%     
==========================================
  Files        1755     1755              
  Lines       77881    77940      +59     
  Branches     6944     6951       +7     
==========================================
+ Hits        37787    38213     +426     
+ Misses      38584    38214     -370     
- Partials     1510     1513       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

github-actions bot commented Aug 7, 2025

Logo
Checkmarx One – Scan Summary & Details19162d26-d20b-47d3-9177-5a4a6955a68e

Great job! No new security vulnerabilities introduced in this pull request

Copy link
Contributor

@coroiu coroiu left a comment

Choose a reason for hiding this comment

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

Clever 👍

Copy link
Contributor

@Thomas-Avery Thomas-Avery left a comment

Choose a reason for hiding this comment

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

LGTM

public required MasterPasswordUnlockKdfResponseModel Kdf { get; init; }
[EncryptedString] public required string MasterKeyEncryptedUserKey { get; init; }
[StringLength(256)] public required string Salt { get; init; }
[Required] public required MasterPasswordUnlockKdfResponseModel Kdf { get; init; }
Copy link
Contributor

Choose a reason for hiding this comment

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

💭 It looks like in newer versions of the swagger NuGet package, the required keyword is honored. Good to know we need both for now.

Copy link
Member

Choose a reason for hiding this comment

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

Should we just update the package in that case?

Copy link

Choose a reason for hiding this comment

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

I would ask the same question. I notice latest is v9.0.3 (releases), and there is a current renovate PR open to upgrade to latest across projects. A review of breaking changes in major 8 and 9 didn't show any immediate smells or suggestions that we'd have a big lift to upgrade the dependency unless there are details I don't know to account for with, e.g. the underlying upgrade to Microsoft.OpenApi in v8.0.0. v8.0.0 would be the first step up from our current, v7.3.2.

Copy link
Member

@Hinton Hinton left a comment

Choose a reason for hiding this comment

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

Suggestion for a more scalable approach if this will be consumed in other places.

If we don't plan on consuming it elsewhere, just adding some boilerplate to the SDK would be preferable.

public required MasterPasswordUnlockKdfResponseModel Kdf { get; init; }
[EncryptedString] public required string MasterKeyEncryptedUserKey { get; init; }
[StringLength(256)] public required string Salt { get; init; }
[Required] public required MasterPasswordUnlockKdfResponseModel Kdf { get; init; }
Copy link
Member

Choose a reason for hiding this comment

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

Should we just update the package in that case?

Comment on lines +36 to +40
var sdkWasmTypes = new[]
{
typeof(UserDecryptionResponseModel), typeof(MasterPasswordUnlockResponseModel),
typeof(MasterPasswordUnlockKdfResponseModel)
};
Copy link
Member

Choose a reason for hiding this comment

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

issue: This is not really scalable if we want to expose more requests/responses this way.

suggestion: You could achieve the same using a custom annotation which gets tagged to the response models and checked in this filter.

@mzieniukbw
Copy link
Contributor Author

Since this change is driven by bitwarden/sdk-internal#376 and i have not been given any confidence in this approach, i am going to close it and revert to TS clients and SDK separation for the responses's model and parsing.

@mzieniukbw mzieniukbw closed this Aug 13, 2025
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.

5 participants