[PR #6936] Replace organization_uuid unwrap with proper error handling #12738

Open
opened 2026-04-20 15:57:49 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/dani-garcia/vaultwarden/pull/6936
Author: @xjohnyknox
Created: 3/13/2026
Status: 🔄 Open

Base: mainHead: fix/remove-unwrap-organization-uuid


📝 Commits (1)

  • 8e78a3b Replace organization_uuid unwrap with proper error handling

📊 Changes

1 file changed (+12 additions, -4 deletions)

View changed files

📝 src/api/core/ciphers.rs (+12 -4)

📄 Description

Summary

The collection update endpoints (post_collections_update and post_collections_admin) call .unwrap() on cipher.organization_uuid in four places. If a cipher without an organization UUID reaches these code paths, the server panics instead of returning an error.

Root cause

cipher.organization_uuid is Option<OrganizationId>. While the earlier is_in_editable_collection_by_user guard should prevent user-owned ciphers from reaching this code, the .unwrap() calls create a hard dependency on that guard — any future changes to the guard logic could silently introduce a panic path.

Fix

Extract organization_uuid early in each function using let Some(ref org_uuid) = ... else { err!(...) }, then reuse the binding throughout. This replaces four .unwrap() calls with a single, clear error return per function.

Test plan

  • Assign a cipher to a collection as a normal org user — should work as before
  • Update collections via admin endpoint — should work as before
  • Attempt to update collections on a cipher with no organization (if reachable) — should return error instead of panicking

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/dani-garcia/vaultwarden/pull/6936 **Author:** [@xjohnyknox](https://github.com/xjohnyknox) **Created:** 3/13/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/remove-unwrap-organization-uuid` --- ### 📝 Commits (1) - [`8e78a3b`](https://github.com/dani-garcia/vaultwarden/commit/8e78a3bfd778cfff4c86ddfb71ea0e67fd60d5ad) Replace organization_uuid unwrap with proper error handling ### 📊 Changes **1 file changed** (+12 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `src/api/core/ciphers.rs` (+12 -4) </details> ### 📄 Description ## Summary The collection update endpoints (`post_collections_update` and `post_collections_admin`) call `.unwrap()` on `cipher.organization_uuid` in four places. If a cipher without an organization UUID reaches these code paths, the server panics instead of returning an error. ### Root cause `cipher.organization_uuid` is `Option<OrganizationId>`. While the earlier `is_in_editable_collection_by_user` guard should prevent user-owned ciphers from reaching this code, the `.unwrap()` calls create a hard dependency on that guard — any future changes to the guard logic could silently introduce a panic path. ### Fix Extract `organization_uuid` early in each function using `let Some(ref org_uuid) = ... else { err!(...) }`, then reuse the binding throughout. This replaces four `.unwrap()` calls with a single, clear error return per function. ## Test plan - [ ] Assign a cipher to a collection as a normal org user — should work as before - [ ] Update collections via admin endpoint — should work as before - [ ] Attempt to update collections on a cipher with no organization (if reachable) — should return error instead of panicking --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-20 15:57:49 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/vaultwarden#12738