Repository navigation
Closed
Labels
Description
Objective
Add warning log messages when float values are silently truncated to integers during type conversion.
Context
Related to discussion #4307. The runtime silently truncates float values to integers without warning, which can cause unexpected behavior when users specify decimal values.
Problem Example
tools:
timeout: 60.5 # User intends 60.5 secondsRuntime behavior: Silently truncates to timeout: 60 with no warning or error.
Approach
- Update type conversion functions to detect float truncation
- Add warning log when precision is lost
- Use the existing logger package following the pattern in other files
- Ensure warnings are helpful but not noisy
Files to Modify
- Update:
pkg/workflow/map_helpers.go(around line 13-14 inparseIntValue()) - Update:
pkg/workflow/metrics.go(around line 253 inConvertToInt()) - Potentially:
pkg/workflow/safe_outputs.go:458for max-patch-size handling
Code Location
Current code in pkg/workflow/map_helpers.go:13-14:
func parseIntValue(value any) (int, bool) {
switch v := value.(type) {
case float64:
return int(v), true // Silent truncation: 60.7 → 60
}
}Proposed enhancement:
func parseIntValue(value any) (int, bool) {
switch v := value.(type) {
case float64:
intVal := int(v)
if v != float64(intVal) {
// Log warning about truncation
log.Printf("WARNING: Float value %v truncated to integer %d", v, intVal)
}
return intVal, true
}
}Acceptance Criteria
- Warning logged when float is truncated to int
- Warning message includes original float value and truncated result
- Warning format:
WARN: [field] value X.Y truncated to X - Logging follows existing logger package patterns
- No warnings for clean conversions (60.0 → 60)
- Unit tests added for truncation scenarios
Testing Notes
Test cases to cover:
60.5→ should warn60.0→ should NOT warn (clean conversion)60→ should NOT warn (already int)- Very large floats that lose precision
AI generated by Plan Command for discussion #4307
Reacted by Copilot
Activity