Skip to content

[Bug]: cron CLI accepts sub-millisecond positive durations as 0ms #100306

Description

@qingminglong

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

The cron CLI accepts positive sub-millisecond durations such as 0.5ms, then floors them to 0ms before sending schedule or failure-alert settings.

Steps to reproduce

  1. On current main at 824d8af0d612fa9e29b910653ac98f6a7495c222, inspect src/cli/cron-cli/shared.ts.
  2. Observe that parseDurationMs("0.5ms") matches the positive duration regex and computes Math.floor(0.5 * 1).
  3. Observe callers such as cron schedule parsing and failure alert cooldown parsing treat the returned numeric value as a parsed duration.

Expected behavior

A positive duration that rounds down to 0ms should be rejected, matching the existing rejection of 0s, so CLI flags do not silently create zero-duration settings.

Actual behavior

0.5ms is accepted by the parser and returned as 0, allowing callers to build zero-millisecond schedule metadata or cooldown values from a user-supplied positive duration.

OpenClaw version

Current main at 824d8af0d612fa9e29b910653ac98f6a7495c222, source-level repro.

Operating system

Not OS-specific.

Install method

Source checkout / pnpm dev.

Model

Not provider-specific; source-level CLI path.

Provider / routing chain

Not provider-specific; source-level CLI path.

Additional provider/model setup details

Not applicable.

Logs, screenshots, and evidence

src/cli/cron-cli/shared.ts parses cron CLI durations with /^(\d+(?:\.\d+)?)(ms|s|m|h|d)$/i, rejects n <= 0, then returns Math.floor(n * factor) without verifying the floored result is still positive.

Existing tests in src/cli/cron-cli/shared.test.ts reject 0s, negative values, malformed values, and overflow, but do not cover positive sub-millisecond inputs that floor to zero.

Duplicate checks found no open issue or PR for:

  • cron 0.5ms duration cooldown stagger every
  • cron duration rounds to zero
  • failure alert cooldown 0ms

Impact and severity

Affected: users editing or creating cron schedules/failure alerts with CLI duration flags.
Severity: Low; edge-case input silently becomes a zero-duration value instead of being rejected.
Frequency: Always for positive duration values below 1ms, such as 0.5ms.
Consequence: Cron schedule metadata or failure alert cooldowns can be created with an unintended 0ms value.

Additional information

NOT_ENOUGH_INFO

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.maturity:stableIssue affects a taxonomy feature currently scored M4/M5.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions