Skip to content

exceptions(metric): MetricTimeoutError drops timeout_seconds=0.0 due to falsy check #68

Description

@himanshu231204

Description

In metric.py, the MetricTimeoutError constructor uses a truthiness check (if timeout_seconds:) to decide whether to include the timeout value in the error details dict:

# line 119
if timeout_seconds:
    error_details["timeout_seconds"] = timeout_seconds

This silently drops timeout_seconds=0.0 because 0.0 is falsy in Python. A timeout of 0.0 seconds (meaning "immediate timeout") is a perfectly valid configuration — it would tell the caller that the metric was expected to finish instantly or be considered timed out.

Impact

When MetricTimeoutError is raised with timeout_seconds=0.0:

  • self.details will NOT contain "timeout_seconds": 0.0
  • str(exc) will NOT show the timeout value (since __str__ in the base class renders self.details)
  • self.timeout_seconds WILL be 0.0 (line 123 stores it regardless), creating a discrepancy between self.details and self.timeout_seconds

Severity

Medium — The bug causes silent loss of diagnostic information for a valid edge case (0-second timeout). The attribute exists on the object but is invisible in string representations and logs.

Affected Code

  • openagent_eval/exceptions/metric.py lines 118-120

Suggested Fix

Use an explicit is not None check instead of truthiness:

if timeout_seconds is not None:
    error_details["timeout_seconds"] = timeout_seconds

(This same pattern of if x: instead of if x is not None: also affects dataset.py:84 (line_number=0) and cli.py:90-93 (field="", value=""), though those edge cases are less likely in practice.)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions