extractEndpointLabel scans steps for the first completed attempt with a non-empty path and returns "METHOD /path" (or just "/path").
(steps []database.ChatDebugStep)
| 192 | // extractEndpointLabel scans steps for the first completed attempt with a |
| 193 | // non-empty path and returns "METHOD /path" (or just "/path"). |
| 194 | func extractEndpointLabel(steps []database.ChatDebugStep) string { |
| 195 | for _, step := range steps { |
| 196 | if len(step.Attempts) == 0 { |
| 197 | continue |
| 198 | } |
| 199 | var attempts []attemptLabel |
| 200 | if err := json.Unmarshal(step.Attempts, &attempts); err != nil { |
| 201 | continue |
| 202 | } |
| 203 | for _, a := range attempts { |
| 204 | if a.Status != attemptStatusCompleted || a.Path == "" { |
| 205 | continue |
| 206 | } |
| 207 | if a.Method != "" { |
| 208 | return a.Method + " " + a.Path |
| 209 | } |
| 210 | return a.Path |
| 211 | } |
| 212 | } |
| 213 | return "" |
| 214 | } |
no test coverage detected