Skip to content

Commit

Permalink
[CWS] fix unmarshalling of regular int to time.Duration (DataDog#31769
Browse files Browse the repository at this point in the history
)
  • Loading branch information
paulcacheux authored Dec 5, 2024
1 parent 6b84c87 commit fef1eb7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/security/secl/rules/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
package rules

import (
"errors"
"fmt"
"time"

"gopkg.in/yaml.v3"
Expand Down Expand Up @@ -219,7 +219,7 @@ func (d *HumanReadableDuration) UnmarshalYAML(n *yaml.Node) error {
return err
}
switch value := v.(type) {
case float64:
case int:
d.Duration = time.Duration(value)
return nil
case string:
Expand All @@ -230,7 +230,7 @@ func (d *HumanReadableDuration) UnmarshalYAML(n *yaml.Node) error {
}
return nil
default:
return errors.New("invalid duration")
return fmt.Errorf("invalid duration: (yaml type: %T)", v)
}
}

Expand Down

0 comments on commit fef1eb7

Please sign in to comment.