Repository navigation
Commit ddc70d9
zhansheng.lzs
refactor(errors): unify SDK error reporting on a central registry
Every failure path used to surface `code="Unknown"` with `status_code=-1`,
leaving callers unable to tell a bad request from a server fault. This routes
all of them through a single registry that separates the public code the caller
sees (`BadRequestError`, `RateLimitError`, ...) from the internal one used for
diagnosis (`sdk.agentic_rl.FunctionTestTimeout`, ...).
Public/internal split:
- Add `dashscope/common/error_registry.py` holding the public errors and the
internal `sdk.*` definitions, each with a message, a solution and its
substitution variables. The file is generator output; all fixes here land on
the consumer side.
- AgentStudio and AgenticRL classify by server code only, so a status can no
longer be contradicted by a message substring.
Classification fixes:
- `verify_function` no longer flattens `AgenticRLError` subclasses and timeouts
into `ValidationError`, which made a failed instance query or a request
timeout look like a 400. It also stopped discarding the reason the deployed
function itself reported.
- Add `TimeoutErrorWithCode` deriving from the builtin `TimeoutError`, so a
wrapped `asyncio.TimeoutError` still reaches the 504 branch on every
supported Python version. Previously it became a 500 and the
`sdk.agentic_rl.FunctionTestTimeout` code was unreachable.
- `AgenticRL.init()` wrapped nothing, so a bad `config_path` leaked a raw
`IOErrorWithCode` with no `status_code` at all. A missing or malformed config
is the caller's to fix and now reports 400.
- A WebSocket handshake 403 was reported as 401, sending callers to rotate an
API key that was in fact valid.
- `AgenticRL.run()` logged only after passing `DashScopeException` straight
through, which left most workflow failures unrecorded.
- The service-unavailable probe matched the bare substring "503", so an address
such as `10.50.30.1:5030` was misread as an outage.
Detail preservation:
- Transport, WebSocket and `iter_over_async` failures keep the originating
exception instead of replacing it with a generic 500 message. `httpx`
timeouts usually carry no message at all, so those fall back to the type name.
- Unparsable SSE bodies report 500 and retain the payload.
- Passing a `requests.Session` to an async call silently ignored it; it now
warns, since only an `aiohttp.ClientSession` can be reused there.
The log-and-classify sequence duplicated across five `AgenticRL` methods is
extracted into `_log_internal_error` / `_public_exception`, and the resulting
record is attributed to the calling handler rather than to the helper.
Tests: 1132 passed, 6 skipped.1 parent 9b2fb54 commit ddc70d9
41 files changed
Lines changed: 5127 additions & 655 deletions
File tree
- dashscope
- acli/examples/dashscope-sdk-expert/.acli/skills
- agentstudio
- api_entities
- audio/qwen_tts_realtime
- client
- cli
- common
- finetune
- reinforcement
- common
- tests/unit
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
76 | | - | |
| 75 | + | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
80 | 85 | | |
81 | 86 | | |
82 | 87 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
17 | 27 | | |
18 | 28 | | |
19 | 29 | | |
20 | 30 | | |
21 | 31 | | |
22 | 32 | | |
23 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
24 | 41 | | |
25 | 42 | | |
26 | 43 | | |
| |||
75 | 92 | | |
76 | 93 | | |
77 | 94 | | |
78 | | - | |
| 95 | + | |
79 | 96 | | |
80 | 97 | | |
81 | 98 | | |
82 | 99 | | |
83 | 100 | | |
84 | | - | |
| 101 | + | |
85 | 102 | | |
86 | 103 | | |
87 | 104 | | |
| |||
90 | 107 | | |
91 | 108 | | |
92 | 109 | | |
93 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
94 | 116 | | |
95 | 117 | | |
96 | 118 | | |
| |||
124 | 146 | | |
125 | 147 | | |
126 | 148 | | |
127 | | - | |
| 149 | + | |
128 | 150 | | |
129 | 151 | | |
130 | 152 | | |
| |||
135 | 157 | | |
136 | 158 | | |
137 | 159 | | |
138 | | - | |
| 160 | + | |
139 | 161 | | |
140 | 162 | | |
141 | 163 | | |
142 | 164 | | |
143 | 165 | | |
144 | | - | |
| 166 | + | |
145 | 167 | | |
146 | 168 | | |
147 | 169 | | |
148 | 170 | | |
149 | 171 | | |
150 | 172 | | |
151 | | - | |
152 | 173 | | |
153 | 174 | | |
154 | 175 | | |
155 | 176 | | |
156 | 177 | | |
157 | 178 | | |
| 179 | + | |
158 | 180 | | |
159 | 181 | | |
160 | 182 | | |
161 | 183 | | |
162 | 184 | | |
163 | 185 | | |
164 | 186 | | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
165 | 190 | | |
166 | 191 | | |
167 | 192 | | |
| 193 | + | |
168 | 194 | | |
169 | 195 | | |
170 | 196 | | |
| 197 | + | |
171 | 198 | | |
| 199 | + | |
172 | 200 | | |
173 | 201 | | |
| 202 | + | |
174 | 203 | | |
175 | 204 | | |
176 | 205 | | |
| |||
179 | 208 | | |
180 | 209 | | |
181 | 210 | | |
182 | | - | |
183 | | - | |
| 211 | + | |
| 212 | + | |
184 | 213 | | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
189 | 218 | | |
190 | 219 | | |
191 | 220 | | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
192 | 226 | | |
193 | 227 | | |
194 | 228 | | |
| |||
211 | 245 | | |
212 | 246 | | |
213 | 247 | | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
220 | 251 | | |
221 | | - | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
222 | 255 | | |
223 | 256 | | |
224 | 257 | | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
225 | 267 | | |
226 | 268 | | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
| 269 | + | |
238 | 270 | | |
239 | 271 | | |
240 | 272 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
207 | 219 | | |
208 | 220 | | |
209 | 221 | | |
| |||
220 | 232 | | |
221 | 233 | | |
222 | 234 | | |
223 | | - | |
| 235 | + | |
224 | 236 | | |
225 | 237 | | |
226 | 238 | | |
| |||
363 | 375 | | |
364 | 376 | | |
365 | 377 | | |
366 | | - | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
367 | 381 | | |
368 | 382 | | |
369 | 383 | | |
370 | 384 | | |
371 | 385 | | |
372 | 386 | | |
373 | | - | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
374 | 390 | | |
375 | 391 | | |
376 | 392 | | |
| |||
587 | 603 | | |
588 | 604 | | |
589 | 605 | | |
590 | | - | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
591 | 609 | | |
592 | 610 | | |
593 | 611 | | |
594 | 612 | | |
595 | 613 | | |
596 | 614 | | |
597 | | - | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
598 | 618 | | |
599 | 619 | | |
600 | 620 | | |
| |||
0 commit comments