mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2026-05-07 03:49:54 -05:00
[PR #7068] fix: return Err instead of panic on unknown cipher atype in to_json() #16756
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/dani-garcia/vaultwarden/pull/7068
Author: @mango766
Created: 4/9/2026
Status: 🔄 Open
Base:
main← Head:fix/cipher-type-panic📝 Commits (1)
d37a0a4fix: return error instead of panicking on invalid cipher type in to_json📊 Changes
1 file changed (+1 additions, -1 deletions)
View changed files
📝
src/db/models/cipher.rs(+1 -1)📄 Description
Fixes #7067
What
Cipher::to_json()returnsResult<Value, Error>but the wildcard arm of theatypematch calledpanic!("Wrong type"). This means if a cipher with an unrecognised type exists in the database, the whole request (and potentially the server) panics instead of failing gracefully.Change
One-line fix — replace
panic!witherr!, which is already used elsewhere in the same file:This lets callers receive a proper
Err, the error gets logged, and the sync request returns a failure response without crashing the server.How it can happen
In all these cases the current code would terminate the Rocket worker thread for every sync request that includes that cipher, affecting all concurrent users.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.