Commit b0b0f31
fix: fail-fast on missing or invalid DCR_ENCRYPTION_KEY
Previously, _encrypt_secret() silently generated an ephemeral Fernet key
when DCR_ENCRYPTION_KEY was not configured. Secrets encrypted with an
ephemeral key become permanently unrecoverable after a container restart.
- Raise RuntimeError in _encrypt_secret() when no Fernet cipher is
available instead of generating an ephemeral key
- Raise ValueError in DCRService.__init__() when DCR_ENCRYPTION_KEY is
missing on Cloud Run (K_SERVICE is set)
- Raise ValueError on invalid DCR_ENCRYPTION_KEY at construction time
instead of logging and continuing with _fernet=None
- Add a stable Fernet key to test conftest so DCR tests have a valid
encryption key available
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 6bb139c commit b0b0f31
2 files changed
Lines changed: 29 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
73 | 74 | | |
74 | 75 | | |
75 | 76 | | |
76 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
77 | 80 | | |
78 | 81 | | |
79 | 82 | | |
80 | 83 | | |
81 | 84 | | |
82 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
83 | 99 | | |
84 | 100 | | |
85 | 101 | | |
| |||
95 | 111 | | |
96 | 112 | | |
97 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
98 | 117 | | |
99 | 118 | | |
100 | | - | |
101 | | - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
102 | 123 | | |
103 | 124 | | |
104 | 125 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
21 | 25 | | |
22 | 26 | | |
23 | 27 | | |
| |||
0 commit comments