Skip to content

Commit 925bf82

Browse files
Potential fix for code scanning alert no. 41: Incorrect conversion between integer types
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 898696e commit 925bf82

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

go/adbc/driver/sparklivy/connection.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"fmt"
2323
"strings"
2424
"time"
25+
"math"
2526

2627
"github.com/apache/arrow-adbc/go/adbc"
2728
"github.com/apache/arrow-adbc/go/adbc/driver/internal/driverbase"
@@ -59,7 +60,12 @@ func (c *connectionImpl) openSession(ctx context.Context) error {
5960

6061
// Add optional parameters
6162
if heartbeat, ok := sessionOpts["heartbeatTimeoutInSecond"].(int64); ok {
62-
req.HeartbeatTimeoutSec = int(heartbeat)
63+
// Only assign if heartbeat fits in int32 and is positive
64+
if heartbeat > 0 && heartbeat <= math.MaxInt32 {
65+
req.HeartbeatTimeoutSec = int(heartbeat)
66+
} else {
67+
// Optionally log, fallback to default, or skip assignment
68+
}
6369
}
6470
if ttl, ok := sessionOpts["ttl"].(string); ok {
6571
req.TTL = ttl

0 commit comments

Comments
 (0)