(ctx context.Context, sessionID string, cwd string, path string)
| 1422 | } |
| 1423 | |
| 1424 | func validateSandboxClientWrittenFile(ctx context.Context, sessionID string, cwd string, path string) error { |
| 1425 | if strings.TrimSpace(sessionID) == "" { |
| 1426 | return nil |
| 1427 | } |
| 1428 | spec, ok := sandboxRuntimeSyntaxCheckSpecForPath(path) |
| 1429 | if !ok { |
| 1430 | return nil |
| 1431 | } |
| 1432 | resp, err := getSandboxClient().ExecuteShell(ctx, sandboxclient.ShellRequest{ |
| 1433 | Command: spec.command, |
| 1434 | Timeout: 20, |
| 1435 | SessionID: sessionID, |
| 1436 | Cwd: cwd, |
| 1437 | EnvVars: map[string]string{"SANDBOX_PREVIEW_PATH": path}, |
| 1438 | }) |
| 1439 | if err != nil { |
| 1440 | return wrapSandboxServiceError(err) |
| 1441 | } |
| 1442 | if resp.ExitCode != 0 { |
| 1443 | return fmt.Errorf("%s syntax validation failed: %s", path, formatCommandResult(resp.Stdout, resp.Stderr, resp.ExitCode)) |
| 1444 | } |
| 1445 | return nil |
| 1446 | } |
| 1447 | |
| 1448 | func parseIntValue(value interface{}, defaultValue int) int { |
| 1449 | switch v := value.(type) { |
no test coverage detected