Commit c9201a1
fix: gate ReadBuffer public API on poison flag
Issue 026 introduced the poison flag so that once a parse error
desynchronizes the stream, subsequent operations fail fast with
ProtocolError. The check was wired into MessageDecoder.decode() /
decode_continuation() but NOT into ReadBuffer's own public API. A
caller holding a raw ReadBuffer (exported from the dqlitewire
package) could keep calling feed()/read_message()/peek_header()/...
after poisoning and re-desynchronize the stream silently.
Gate every mutating/consuming public method on ReadBuffer on
self._check_poisoned(): feed, read_message, skip_message,
read_bytes, peek_bytes, peek_header. Observers (has_message,
available, is_poisoned, is_skipping) and recovery primitives
(clear, reset, poison) remain total and do not raise.
Two existing TestDecoderPoisonedState tests pushed bytes through
feed() after a poison to assert that the sticky state survived.
That contract is now stricter: feed() itself refuses, which
surfaces the poison earlier. Update the tests to assert
ProtocolError on the feed() call and still require reset() for
recovery.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent ec2bf58 commit c9201a1
3 files changed
Lines changed: 78 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
95 | 98 | | |
| 99 | + | |
96 | 100 | | |
97 | 101 | | |
98 | 102 | | |
| |||
146 | 150 | | |
147 | 151 | | |
148 | 152 | | |
| 153 | + | |
| 154 | + | |
149 | 155 | | |
| 156 | + | |
150 | 157 | | |
151 | 158 | | |
152 | 159 | | |
| |||
174 | 181 | | |
175 | 182 | | |
176 | 183 | | |
| 184 | + | |
177 | 185 | | |
| 186 | + | |
178 | 187 | | |
179 | 188 | | |
180 | 189 | | |
| |||
212 | 221 | | |
213 | 222 | | |
214 | 223 | | |
| 224 | + | |
| 225 | + | |
215 | 226 | | |
| 227 | + | |
216 | 228 | | |
217 | 229 | | |
218 | 230 | | |
| |||
244 | 256 | | |
245 | 257 | | |
246 | 258 | | |
| 259 | + | |
247 | 260 | | |
| 261 | + | |
248 | 262 | | |
249 | 263 | | |
250 | 264 | | |
| |||
260 | 274 | | |
261 | 275 | | |
262 | 276 | | |
| 277 | + | |
| 278 | + | |
263 | 279 | | |
| 280 | + | |
264 | 281 | | |
265 | 282 | | |
266 | 283 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
219 | 270 | | |
220 | 271 | | |
221 | 272 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1015 | 1015 | | |
1016 | 1016 | | |
1017 | 1017 | | |
1018 | | - | |
1019 | | - | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
1020 | 1023 | | |
1021 | 1024 | | |
1022 | 1025 | | |
| |||
1108 | 1111 | | |
1109 | 1112 | | |
1110 | 1113 | | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
1111 | 1117 | | |
1112 | | - | |
| 1118 | + | |
| 1119 | + | |
1113 | 1120 | | |
1114 | 1121 | | |
1115 | 1122 | | |
| |||
0 commit comments