Skip to content

Commit e0f5c01

Browse files
joostboonclaude
andauthored
fix: handle fractional day conversion for hour-based detection periods (#914)
When detection_period uses period: hour with small counts (e.g., 2), the conversion to days produces fractional results (2/24 = 0.083). Previously, casting to int yielded 0, which then failed validation because the check used "if not value" (treating 0 as falsy). Changes: 1. Use ceil() in convert_period to round up fractional days, ensuring at least 1 day of backfill data when using hourly periods 2. Fix validation logic to check "is none" instead of "not value", properly distinguishing between missing (None) and zero (0) values This ensures that configurations like: detection_period: {period: hour, count: 2} now correctly convert to 1 day instead of 0, and that explicit zero values are accepted as valid if provided. Fixes issue where volume_anomalies test with hourly detection periods would incorrectly report "Missing mandatory configuration: ['backfill_days']" Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent fc97b29 commit e0f5c01

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

macros/edr/tests/test_configuration/get_anomalies_test_configuration.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
{%- endif %}
100100

101101
{%- for mandatory_param in mandatory_configuration %}
102-
{%- if not test_configuration.get(mandatory_param) %}
102+
{%- if test_configuration.get(mandatory_param) is none %}
103103
{%- do missing_mandatory_params.append(mandatory_param) -%}
104104
{%- endif %}
105105
{%- endfor %}

macros/edr/tests/test_configuration/get_period_vars.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,6 @@
8383
{% endif %}
8484
{% endif %}
8585

86-
{% set period_count = period_count | int %}
86+
{% set period_count = (period_count | round(0, 'ceil')) | int %}
8787
{{ return({'period': convert_to, 'count': period_count}) }}
8888
{% endmacro %}

0 commit comments

Comments
 (0)