Commit 3100ac1
fix: make ReadBuffer.has_message() total (non-raising)
has_message() is a predicate and must not raise — the documented
`while decoder.has_message(): decode()` pattern required callers to
wrap the check itself in try/except to handle oversized headers.
Move the max_message_size check into read_message() so the error
surfaces at consume time. has_message() now returns True when a
header claims an oversized body, signalling "there is something to
consume; the consume call will tell you whether it's valid."
skip_message() is unchanged — it already handles the oversized path
as the documented recovery mechanism.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 5480e73 commit 3100ac1
3 files changed
Lines changed: 64 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
71 | 78 | | |
72 | 79 | | |
73 | 80 | | |
| |||
78 | 85 | | |
79 | 86 | | |
80 | 87 | | |
81 | | - | |
82 | | - | |
83 | | - | |
| 88 | + | |
| 89 | + | |
84 | 90 | | |
85 | 91 | | |
86 | 92 | | |
| |||
104 | 110 | | |
105 | 111 | | |
106 | 112 | | |
| 113 | + | |
| 114 | + | |
107 | 115 | | |
108 | | - | |
| 116 | + | |
| 117 | + | |
109 | 118 | | |
110 | 119 | | |
111 | 120 | | |
112 | 121 | | |
113 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
114 | 131 | | |
115 | 132 | | |
116 | 133 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
145 | 171 | | |
146 | | - | |
| 172 | + | |
147 | 173 | | |
148 | 174 | | |
149 | 175 | | |
| |||
154 | 180 | | |
155 | 181 | | |
156 | 182 | | |
| 183 | + | |
| 184 | + | |
157 | 185 | | |
158 | | - | |
| 186 | + | |
159 | 187 | | |
160 | 188 | | |
161 | 189 | | |
| |||
179 | 207 | | |
180 | 208 | | |
181 | 209 | | |
182 | | - | |
| 210 | + | |
| 211 | + | |
183 | 212 | | |
184 | | - | |
| 213 | + | |
185 | 214 | | |
186 | 215 | | |
187 | 216 | | |
| |||
218 | 247 | | |
219 | 248 | | |
220 | 249 | | |
| 250 | + | |
221 | 251 | | |
222 | | - | |
| 252 | + | |
223 | 253 | | |
224 | 254 | | |
225 | 255 | | |
| |||
251 | 281 | | |
252 | 282 | | |
253 | 283 | | |
| 284 | + | |
254 | 285 | | |
255 | | - | |
| 286 | + | |
256 | 287 | | |
257 | 288 | | |
258 | 289 | | |
| |||
274 | 305 | | |
275 | 306 | | |
276 | 307 | | |
| 308 | + | |
277 | 309 | | |
278 | | - | |
| 310 | + | |
279 | 311 | | |
280 | 312 | | |
281 | 313 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
862 | 862 | | |
863 | 863 | | |
864 | 864 | | |
865 | | - | |
| 865 | + | |
| 866 | + | |
866 | 867 | | |
867 | | - | |
| 868 | + | |
868 | 869 | | |
869 | 870 | | |
870 | 871 | | |
| |||
0 commit comments