Skip to content

fix(crypto): wrap non UTF8 plaintext in the safe decrypt error - #30

Merged
MugdhoAI merged 1 commit into
mainfrom
fix-crypto-non-utf8-decrypt
Nov 14, 2026
Merged

MugdhoAI merged 1 commit into
mainfrom
fix-crypto-non-utf8-decrypt

Conversation

@MugdhoAI

Copy link
Copy Markdown
Owner

decrypt_value only caught InvalidToken, so a valid Fernet token whose plaintext is not UTF8 raised a raw UnicodeDecodeError instead of the documented ValueError with the message Stored secret cannot be decrypted. Callers and the key rotation script rely on that contract. This change catches UnicodeDecodeError alongside InvalidToken and adds a regression test using a Fernet token that encrypts non UTF8 bytes.

Local test evidence: full pytest suite run locally with a SQLite test database, 36 passed (35 baseline plus 1 new test).

@MugdhoAI
MugdhoAI merged commit 3a81f84 into main Nov 14, 2026
4 checks passed
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.

1 participant