(field string, raw string)
| 440 | } |
| 441 | |
| 442 | func parseToolInputJSON(field string, raw string) (json.RawMessage, error) { |
| 443 | trimmed := strings.TrimSpace(raw) |
| 444 | if trimmed == "" { |
| 445 | return nil, toolspkg.NewValidationError(field, toolspkg.ReasonSchemaInvalid, "input JSON is required") |
| 446 | } |
| 447 | var compacted bytes.Buffer |
| 448 | if err := json.Compact(&compacted, []byte(trimmed)); err != nil { |
| 449 | return nil, toolspkg.NewValidationError(field, toolspkg.ReasonSchemaInvalid, "input must be valid JSON") |
| 450 | } |
| 451 | return json.RawMessage(compacted.String()), nil |
| 452 | } |
| 453 | |
| 454 | func writeToolCommandError(cmd *cobra.Command, err error) error { |
| 455 | if err == nil { |
no test coverage detected