fix(crypto): raise clear EncryptionError for invalid Fernet key (BIT-33939) #11

Closed
bug-squasher wants to merge 1 commits from task/BIT-33939-fernet-key-validation into main
pull from: task/BIT-33939-fernet-key-validation
1 Commits
Author SHA1 Message Date
Xika 1243c7db57 fix(crypto): raise clear EncryptionError for invalid Fernet key (BIT-33939)
ci / verify (pull_request) Successful in 50s
get_fernet() let Fernet() raise a raw ValueError when ENCRYPTION_KEY was
malformed (e.g. the 'change_me_fernet_key' placeholder shipped in
.env.example), crashing the WebDAV sync loop with a cryptic
'Fernet key must be 32 url-safe base64-encoded bytes.' message.

Guard the Fernet() construction so an invalid key raises EncryptionError
with actionable guidance pointing at Fernet.generate_key(). Also blank
the invalid placeholder in .env.example so it cannot be copied verbatim
into production.

Paperclip-Issue: BIT-33939
2026-12-04 10:16:50 +00:00