[rust][contacts] add shared contacts client and bridge#9957
[rust][contacts] add shared contacts client and bridge#9957ua741 merged 20 commits intoente-io:mainfrom
Conversation
|
@codex Review these changes |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 58c52c5088
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Follow-up on the I did a repo scan of Rust call sites after the review comment. Today, the redirect-sensitive paths are the raw-byte helpers ( The problem with the previous code was that reqwest's default auto-redirects could bypass that manual policy entirely, so a cross-origin hop could happen before our code had a chance to drop Ente auth headers. I also checked current Rust usage of I considered narrowing this to a second redirectless client only for the byte-transfer paths. That would work, but it adds extra client plumbing/state for little practical benefit given current usage. I chose the global I also added a regression test proving that a cross-origin redirect on |
|
@codex Review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b2aa4df3f2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Quick follow-up on the latest two comments:
Instead of disabling redirects on the shared authenticated client, I also added a regression test that
The goal here is still to allow local decrypt/use of a cached root key without turning server-backed reads into an extra confirmation round-trip every time. The important correctness fix was the create-race path: if we lose the So after this update:
If we later want an extra self-heal path for already-bad persisted state, I think the right shape is a one-time retry-on-decrypt-failure in the read path, not unconditional confirmation on every read. |
|
@codex Review again |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2429dac0ed
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
rust/contacts/src/client.rs
Outdated
| Err(HttpError::Http { .. }) => { | ||
| if let Some(remote_root_key) = fetch_root_key(http).await? { | ||
| Ok(Some(remote_root_key)) | ||
| } else { | ||
| Err(HttpError::Http { |
There was a problem hiding this comment.
Propagate non-conflict create-root errors
The create_root_key helper treats every HTTP failure from POST /user-entity/key as a race and falls back to a fetch, then fabricates a 500 if that fetch returns nothing. That masks real failures (for example, a 400 validation error on the POST) and returns the wrong status/message to callers, which makes retry and diagnostics logic unreliable. Restrict the fallback path to the expected conflict status and otherwise return the original HTTP error.
Useful? React with 👍 / 👎.
| self.object_store_http | ||
| .get_bytes(&download.url) | ||
| .await | ||
| .map_err(Into::into) |
There was a problem hiding this comment.
Make generic attachment get/set behavior symmetric
set_attachment encrypts attachment bytes before upload, but get_attachment returns raw downloaded bytes without decrypting. Since AttachmentType currently only exposes ProfilePicture, this makes the generic API non-roundtrippable for its only supported type and returns ciphertext that callers cannot decrypt through this public surface. Either decrypt in get_attachment (with required contact context) or clearly split encrypted-vs-decrypted APIs.
Useful? React with 👍 / 👎.
| serde_json::from_slice(&plaintext).map_err(|e| { | ||
| CryptoError::InvalidKeyDerivationParams(format!("JSON deserialization failed: {}", e)) | ||
| }) |
There was a problem hiding this comment.
Classify combined JSON decode failures as JSON errors
decrypt_json_combined maps serde deserialization failures to InvalidKeyDerivationParams, unlike the existing JSON helpers that return CryptoError::Json. This mislabels payload/schema issues as KDF problems, so error handling and telemetry get the wrong category and message. Use the JSON error variant here for consistency with the rest of the blob JSON API.
Useful? React with 👍 / 👎.
|
No dependency changes detected. Learn more about Socket for GitHub. 👍 No dependency changes detected in pull request |
1c6ace7 to
a034177
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Head branch was pushed to by a user without write access
Summary
This PR adds the shared Rust contacts client and the supporting Rust core HTTP changes needed to use it from downstream mobile and web integrations.
What changed
rust/contactscrate for contact sync, root-key handling, create/update/delete flows, and profile-picture attachment operationsrust/corefor presigned upload/download flows without Ente auth headersrust/coreso the Rust/WASM stack compiles cleanlyWhy
The contacts backend from PR1 needs a reusable Rust client layer before mobile and web integrations can build on top of it. This PR creates that shared domain/client surface and the supporting HTTP plumbing.
Validation
cargo test --manifest-path rust/contacts/Cargo.tomlcargo clippy --manifest-path rust/contacts/Cargo.toml --all-targets -- -D warningscargo check --manifest-path rust/core/Cargo.toml