Skip to content

[PM-18042] Build request response structure #275

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 34 commits into from
Jun 25, 2025

Conversation

coroiu
Copy link
Contributor

@coroiu coroiu commented May 14, 2025

🎟️ Tracking

📔 Objective

⏰ 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

Copy link
Contributor

github-actions bot commented May 14, 2025

Logo
Checkmarx One – Scan Summary & Detailsefff70a0-4890-4bcc-93db-30a13d861433

Great job, no security vulnerabilities found in this Pull Request

Base automatically changed from PM-20615-only-process-incoming-messages-once to main June 11, 2025 13:49
@coroiu coroiu force-pushed the PM-18042-build-request-response-structure branch from 762113a to 43882f0 Compare June 12, 2025 10:24
Copy link

codecov bot commented Jun 12, 2025

Codecov Report

Attention: Patch coverage is 83.19088% with 59 lines in your changes missing coverage. Please review.

Project coverage is 71.38%. Comparing base (a3d748a) to head (76f74f5).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
crates/bitwarden-ipc/src/rpc/exec/handler.rs 18.51% 22 Missing ⚠️
crates/bitwarden-ipc/src/wasm/discover.rs 0.00% 20 Missing ⚠️
crates/bitwarden-ipc/src/ipc_client.rs 96.39% 7 Missing ⚠️
crates/bitwarden-ipc/src/discover/mod.rs 0.00% 6 Missing ⚠️
crates/bitwarden-ipc/src/rpc/error.rs 0.00% 3 Missing ⚠️
crates/bitwarden-ipc/src/message.rs 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #275      +/-   ##
==========================================
+ Coverage   71.18%   71.38%   +0.19%     
==========================================
  Files         230      237       +7     
  Lines       18634    18938     +304     
==========================================
+ Hits        13265    13519     +254     
- Misses       5369     5419      +50     

☔ 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.

Comment on lines 18 to 32
impl TryFrom<Vec<u8>> for RpcRequestMessage {
type Error = serde_json::Error;

fn try_from(value: Vec<u8>) -> Result<Self, Self::Error> {
serde_json::from_slice(&value)
}
}

impl TryFrom<RpcRequestMessage> for Vec<u8> {
type Error = serde_json::Error;

fn try_from(value: RpcRequestMessage) -> Result<Self, Self::Error> {
serde_json::to_vec(&value)
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

thought: this is another thing I'm a bit divided on; the levels of serialization. At this point we don't know how to deserialize the request (because we don't know its type) but we still need to wrap it somehow and so we end up with a nested Vec<u8> field which contains the actual request data. This will then be deserialized by the rpc handler

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Technically RPC can be seen as built on top of the req/res paradigm that the IPC client provides at its core, that's why we are actually defining a serilalization format (serde_json) here, because it's RPC over TypedMessages

@coroiu coroiu requested a review from dani-garcia June 13, 2025 13:30
@coroiu coroiu marked this pull request as ready for review June 13, 2025 13:30
@coroiu coroiu requested a review from a team as a code owner June 13, 2025 13:30
coroiu and others added 3 commits June 23, 2025 11:48
## 🎟️ Tracking

<!-- Paste the link to the Jira or GitHub issue or otherwise describe /
point to where this change is coming from. -->

## 📔 Objective

Refactoring the IPC to use serde instead. Putting this in a separate PR
to make reviewing easier

## ⏰ 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

<!-- Suggested interactions but feel free to use (or not) as you desire!
-->

- 👍 (`:+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
Copy link
Member

@dani-garcia dani-garcia left a comment

Choose a reason for hiding this comment

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

Some minor comments now that we have everything together, the rest looks pretty good to me!

bitwarden-error = { workspace = true }
bitwarden-threading = { workspace = true }
erased-serde = "0.4.6"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
erased-serde = "0.4.6"
erased-serde = ">=0.4.6, <0.5"

type Response: Serialize + DeserializeOwned + 'static;

/// Used to identify handlers
fn name() -> String;
Copy link
Member

Choose a reason for hiding this comment

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

For some other traits, instead of a function we use an associated constant, like on PayloadTypeName, should we do the same here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, yes, I only recently discovered that you could use constants like this (during a review I think) so I just missed updating this :)

&self.partial.request_type
}

pub fn full<T>(&self) -> Result<RpcRequestMessage<T>, RpcError>
Copy link
Member

Choose a reason for hiding this comment

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

full is a bit of a strange name for a function, maybe deserialize_full to be more clear?

Copy link

@coroiu coroiu requested a review from dani-garcia June 25, 2025 09:04
@coroiu coroiu merged commit 025f818 into main Jun 25, 2025
43 checks passed
@coroiu coroiu deleted the PM-18042-build-request-response-structure branch June 25, 2025 11:30
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.

2 participants