(raw any)
| 186 | } |
| 187 | |
| 188 | func parseAgentTimeoutSeconds(raw any) (int, string) { |
| 189 | if raw == nil { |
| 190 | return DefaultSubagentTimeoutSeconds, "" |
| 191 | } |
| 192 | switch v := raw.(type) { |
| 193 | case int: |
| 194 | return validateAgentTimeoutSeconds(v) |
| 195 | case int32: |
| 196 | return validateAgentTimeoutSeconds(int(v)) |
| 197 | case int64: |
| 198 | return validateAgentTimeoutSeconds(int(v)) |
| 199 | case float32: |
| 200 | return validateAgentTimeoutSeconds(int(v)) |
| 201 | case float64: |
| 202 | return validateAgentTimeoutSeconds(int(v)) |
| 203 | case json.Number: |
| 204 | n, err := v.Int64() |
| 205 | if err != nil { |
| 206 | return 0, "timeout_seconds must be an integer number of seconds." |
| 207 | } |
| 208 | return validateAgentTimeoutSeconds(int(n)) |
| 209 | case string: |
| 210 | text := strings.TrimSpace(strings.TrimSuffix(v, "s")) |
| 211 | if text == "" { |
| 212 | return 0, "timeout_seconds must not be empty." |
| 213 | } |
| 214 | n, err := strconv.Atoi(text) |
| 215 | if err != nil { |
| 216 | return 0, "timeout_seconds must be an integer number of seconds." |
| 217 | } |
| 218 | return validateAgentTimeoutSeconds(n) |
| 219 | default: |
| 220 | return 0, fmt.Sprintf("timeout_seconds must be an integer number of seconds, got %T.", raw) |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | func validateAgentTimeoutSeconds(seconds int) (int, string) { |
| 225 | if seconds <= 0 { |
no test coverage detected