Commit f5983d5
authored
proto: make invalid UTF-8 errors non-fatal (#660)
The current logic currently treats RequredNotSetError as a non-fatal
error such that it continues to proceed with its normal execution, but
returns that non-fatal error at the end.
We now make it such that invalid UTF-8 is also a distinguishable error
that is treated as non-fatal by the execution logic. In the rare event
that both an RequiredNotSet error and InvalidUTF8 error is encountered,
the first one encountered is returned.
In the process of making this change, we also fix a number of cases where
RequiredNotSet was treated as fatal, when it should not have been non-fatal
(notably in the logic for extensions, message sets, and maps).
This change deliberately does not provide an API make it easy to distinguish
invalid UTF-8 errors as this is not a normal behavior we want users to
depend on. We can always expose additional API for this in the future.
Users can test for invalid UTF-8 with:
re, ok := err.(interface{ InvalidUTF8() bool })
isInvalidUTF8 := ok && re.InvalidUTF8()1 parent 560bdb6 commit f5983d5
File tree
5 files changed
+169
-94
lines changed- proto
5 files changed
+169
-94
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2256 | 2256 | | |
2257 | 2257 | | |
2258 | 2258 | | |
| 2259 | + | |
2259 | 2260 | | |
2260 | 2261 | | |
2261 | 2262 | | |
2262 | 2263 | | |
| 2264 | + | |
2263 | 2265 | | |
2264 | 2266 | | |
2265 | 2267 | | |
2266 | 2268 | | |
| 2269 | + | |
2267 | 2270 | | |
2268 | 2271 | | |
2269 | 2272 | | |
2270 | 2273 | | |
| 2274 | + | |
2271 | 2275 | | |
2272 | 2276 | | |
2273 | 2277 | | |
2274 | 2278 | | |
| 2279 | + | |
2275 | 2280 | | |
2276 | 2281 | | |
2277 | 2282 | | |
2278 | 2283 | | |
| 2284 | + | |
2279 | 2285 | | |
2280 | 2286 | | |
2281 | 2287 | | |
| |||
2284 | 2290 | | |
2285 | 2291 | | |
2286 | 2292 | | |
2287 | | - | |
2288 | | - | |
2289 | | - | |
| 2293 | + | |
| 2294 | + | |
| 2295 | + | |
| 2296 | + | |
| 2297 | + | |
| 2298 | + | |
| 2299 | + | |
2290 | 2300 | | |
2291 | 2301 | | |
| 2302 | + | |
| 2303 | + | |
| 2304 | + | |
2292 | 2305 | | |
2293 | 2306 | | |
2294 | | - | |
| 2307 | + | |
2295 | 2308 | | |
2296 | 2309 | | |
2297 | 2310 | | |
2298 | | - | |
2299 | | - | |
| 2311 | + | |
| 2312 | + | |
| 2313 | + | |
| 2314 | + | |
| 2315 | + | |
| 2316 | + | |
| 2317 | + | |
2300 | 2318 | | |
2301 | 2319 | | |
2302 | 2320 | | |
| 2321 | + | |
| 2322 | + | |
| 2323 | + | |
2303 | 2324 | | |
2304 | 2325 | | |
2305 | 2326 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
41 | 40 | | |
42 | 41 | | |
43 | 42 | | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | 43 | | |
59 | 44 | | |
60 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
265 | 265 | | |
266 | 266 | | |
267 | 267 | | |
268 | | - | |
269 | 268 | | |
270 | 269 | | |
271 | 270 | | |
| |||
274 | 273 | | |
275 | 274 | | |
276 | 275 | | |
277 | | - | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
278 | 336 | | |
279 | 337 | | |
280 | 338 | | |
| |||
0 commit comments