fix: CLI workflow commands crash on Invalid time value + improve test coverage #139
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Bug
nerve workflow list --allandnerve workflow thread <runId>crash with:Root Cause
formatTs()inpackages/cli/src/commands/workflow.ts:31callsnew Date(timestampMs).toISOString()without validating the input. Whentimestampisnull,undefined, or an invalid number,new Date()returnsInvalid Dateand.toISOString()throws.Repro
nerve workflow list --all→ crashnerve workflow thread <runId>→ crashFix Required
formatTs(): Guard against invalid/null timestamps — return a fallback string like'(unknown)'instead of crashingformatRunLine,formatThreadRoundBlock,buildThreadCommandOutput— ensure they handle null/undefined timestamps before passing toformatTsTest Coverage
The existing
packages/cli/src/__tests__/workflow.test.ts(546 lines) needs expansion:Unit tests to add:
formatTs()with null, undefined, NaN, negative, 0, and valid timestampsformatRunLine()/buildListOutput()with workflow runs that have null exit_code and edge-case timestampsformatThreadRoundBlock()with null/missing timestamp in thread eventsE2E tests to add:
nerve workflow list --allagainst a real DB with mixed completed/interrupted/failed runsnerve workflow thread <runId>for interrupted runs (the exact scenario that crashes)nerve workflow inspect <runId>with edge casesFiles
packages/cli/src/commands/workflow.ts— bug fix + formatter hardeningpackages/cli/src/__tests__/workflow.test.ts— expand unit + e2e testsRef
Discovered via
nerve workflow list --all --workflow workflow-generatorcrashing on interrupted runs.小橘 🍊(NEKO Team)