Repository navigation
Commit 4517882
authored
grpc/service_config: Handle deserialization edge cases (#2899)
## Motivation
There are a couple of cases where the expected behavior doesn't match
the actual behavior:
### GrpcDuration (The "timeout" field)
| Input | Expected per Protobuf JSON spec | Actual (current) result |
| :--- | :--- | :--- |
| `"+1s"` | `Err` (leading `+` is not valid) | `Ok(1s)` |
| `"1.+5s"` | `Err` (`+` is not valid in fractional seconds) |
`Ok(1.05s)` |
| `"315576000001s"` | `Err` (exceeds Protobuf max of `315_576_000_000s`)
| `Ok(315576000001s)` |
### SerdeU32 (e.g. "maxRequestMessageBytes" field)
| Input | Expected per Protobuf JSON spec | Actual (current) result |
| :--- | :--- | :--- |
| `"+5"` | `Err` (leading `+` is not valid in a `uint32` string) |
`Ok(5)` |
| `1024.0` | `Ok(1024)` (integer-valued floats for int fields allowed) |
`Err("invalid type: floating point \`1024.0\`...")` |
| `1e3` | `Ok(1000)` (exp. notation for int fields allowed) |
`Err("invalid type: floating point \`1000.0\`...")` |
<!--
Explain the context and why you're making that change. What is the
problem
you're trying to solve? If a new feature is being added, describe the
intended
use case that feature fulfills.
-->
## Solution
Small fixes to the parsing, update the test cases to cover this.1 parent f91ee92 commit 4517882
2 files changed
Lines changed: 44 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
| 69 | + | |
68 | 70 | | |
69 | 71 | | |
70 | 72 | | |
71 | | - | |
72 | | - | |
| 73 | + | |
| 74 | + | |
73 | 75 | | |
74 | 76 | | |
75 | 77 | | |
| |||
79 | 81 | | |
80 | 82 | | |
81 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
82 | 87 | | |
83 | 88 | | |
84 | 89 | | |
| |||
109 | 114 | | |
110 | 115 | | |
111 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
112 | 121 | | |
113 | 122 | | |
114 | 123 | | |
| |||
126 | 135 | | |
127 | 136 | | |
128 | 137 | | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
129 | 141 | | |
130 | 142 | | |
131 | 143 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
208 | 220 | | |
209 | 221 | | |
210 | 222 | | |
211 | 223 | | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
212 | 227 | | |
213 | 228 | | |
214 | 229 | | |
| |||
315 | 330 | | |
316 | 331 | | |
317 | 332 | | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
318 | 339 | | |
319 | 340 | | |
320 | 341 | | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
321 | 348 | | |
322 | 349 | | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
323 | 353 | | |
324 | 354 | | |
325 | 355 | | |
| |||
0 commit comments