Skip to content

Reject start dates after end dates #1

@MChartier

Description

@MChartier

Summary

lg fetch/lg sync accepts a start date that is later than the end date because the validation compares isAfter(start, addDays(end, 1)). Adding a day to the end makes ranges where start is exactly one day after end pass the check, so the CLI keeps running instead of rejecting the parameters.

Steps to Reproduce

  1. Run node lg.mjs fetch --enrollment fake --start 2024-01-10 --end 2024-01-09.
  2. Commander parses the options and the process keeps going instead of exiting with the "Invalid range" message.

Expected Result

The CLI should stop immediately with a validation error when start is after end.

Actual Result

The validation is skipped, the API request is attempted, and users get confusing empty results.

Additional Context

This lives in lg.mjs inside normalizeFetchOptions around line 314. Using addDays(end, 1) effectively allows start === end + 1 day. Replacing the check with a direct isAfter(start, end) (and optionally handling invalid ISO strings) would block bad ranges.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions