Validate that start date precedes end date - #192
Merged
Conversation
The CLI validator parsed --start-date and --end-date for ISO format but never checked their order, so an inverted range was sent to CMR and the user only saw an opaque HTTP 400 at request time. Raise a clear error when start is later than end. Equal dates stay allowed. Fixes #145 Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
Contributor
|
Thanks for the PR, @arpitjain099, it looks great! The only minor suggestion I'd make is to update the error message to "--end-date must be greater than or equal to --start-date." since the implementation allows equal dates. |
Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
Contributor
Author
|
Good catch, thanks. Updated the message to "--end-date must be greater than or equal to --start-date." so it lines up with the equal-dates case being allowed. Pushed to the same branch. |
viviant100
approved these changes
Jun 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Right now the start and end dates aren't checked against each other, so if you pass a start date that's later than the end date the bad range just gets sent to CMR and all you see is an HTTP 400, which is pretty confusing. This adds an order check so you get a clear message instead, using the wording suggested in #145. Equal start and end dates are still allowed.
I added a couple of assertions to test_validate covering both the out-of-order case and the equal-dates case. Thanks for taking a look.