Commit 5a91c48
ralphstodomingo
fix: surface a clear error on non-JSON API responses instead of crashing
When a proxy, gateway or CDN returns an HTTP 200 with an HTML body (an error
or interstitial page) instead of JSON, the generated SDK client JSON-parses it
and throws a raw `JSON Parse error: Unrecognized token '<'`. `parseAs` falls
back to "json" whenever Content-Type is missing or unrecognized, so a non-JSON
body reaches the parser. The error path was already guarded; the success path
was not.
Guard the JSON parse in both the v1 and v2 generated clients: on a parse
failure, throw an actionable error (non-JSON response, likely a proxy/gateway
error page, with HTTP status + content-type) instead of the raw parse crash.
Surfaced from telemetry as a recurring extension sendMessageError.1 parent 54a8f32 commit 5a91c48
2 files changed
Lines changed: 27 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
118 | 132 | | |
119 | 133 | | |
120 | 134 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
173 | 185 | | |
174 | 186 | | |
175 | 187 | | |
| |||
0 commit comments