Skip to content

fix: validate -s/--start flag and error on unparseable values#259

Merged
Sladuca merged 2 commits intomainfrom
fix/validate-start-time-flag
Mar 27, 2026
Merged

fix: validate -s/--start flag and error on unparseable values#259
Sladuca merged 2 commits intomainfrom
fix/validate-start-time-flag

Conversation

@Sladuca
Copy link
Copy Markdown
Contributor

@Sladuca Sladuca commented Mar 27, 2026

Summary

The -s/--start flag silently accepted any string. When chrono-node couldn't parse the input, the argParser fell back to "NOW" with no error — the command would proceed as if -s hadn't been passed at all.

Added a strict argParser that calls logAndQuit with a clear message when the input can't be parsed as a date.

Before (bad input silently treated as NOW):

$ sf nodes create -n 1 -d "4h" -s "test minimal request" -p 24
ℹ Using start time: Today, 9:35am PDT
...

After:

$ sf nodes create -n 1 -d "4h" -s "test minimal request" -p 24
Invalid start time: "test minimal request". Use ISO 8601 format (e.g. '2024-01-15T10:00:00Z'), a relative time (e.g. '+1h'), or 'NOW'.

Valid inputs still work as expected:

$ sf nodes create -n 1 -d "1h" -s "+1h" -p 24
✔ Start time must be "NOW" or on an hour boundary. Choose a time: Today, 11am PDT
✔ Create 1 reserved node for ~$14.78/node/hr on richmond? Yes
✔ Successfully created 1 reserved node

🤖 Generated with Claude Code

Sladuca and others added 2 commits March 27, 2026 09:54
Previously, passing an invalid string to -s/--start (e.g. a typo or
free-form text) would silently fall back to NOW via chrono-node's
parseDate returning null. The command would then proceed as if no start
time was specified.

Now the argParser throws a CommanderError with a clear message when the
input cannot be parsed as a date.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@semanticdiff-com
Copy link
Copy Markdown

semanticdiff-com bot commented Mar 27, 2026

Review changes with  SemanticDiff

Changed Files
File Status
  src/lib/nodes/utils.ts  0% smaller

@joshi4 joshi4 self-requested a review March 27, 2026 17:29
Copy link
Copy Markdown
Contributor

@joshi4 joshi4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Sladuca Sladuca merged commit ca79df3 into main Mar 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants