Revert "Merge pull request #117 from ChanukaUOJ/fix/enable-max-date-c…#118
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a check to limit the number of requested dates in fetch_cabinet_flow to prevent excessive queries, raising a BadRequestError if exceeded. However, changing the minimum dates validation from len(dates) < 2 to len(dates) == 1 inadvertently allows empty lists to bypass validation. The feedback recommends reverting this check to len(dates) < 2 and restoring the parameterized test coverage for both empty and single-element lists.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if len(dates) == 1: | ||
| raise ValueError("At least 2 dates required for the comparison") |
There was a problem hiding this comment.
Changing the validation from len(dates) < 2 to len(dates) == 1 allows an empty list of dates (len(dates) == 0) to bypass this check without raising a ValueError. Since at least 2 dates are required for comparison, an empty list should also be rejected. Using len(dates) < 2 correctly handles both empty and single-element lists.
| if len(dates) == 1: | |
| raise ValueError("At least 2 dates required for the comparison") | |
| if len(dates) < 2: | |
| raise ValueError('At least 2 dates required for the comparison') |
| @pytest.mark.asyncio | ||
| @pytest.mark.parametrize("dates", [[], ["2024-09-23"]]) | ||
| async def test_fetch_cabinet_flow_insufficient_dates(organisation_service, dates): | ||
| async def test_fetch_cabinet_flow_single_date_fails(organisation_service): | ||
| president_id = "pres1" | ||
| dates = ["2024-09-23"] | ||
|
|
||
| with pytest.raises(ValueError): | ||
| await organisation_service.fetch_cabinet_flow(president_id, dates) |
There was a problem hiding this comment.
Restore the parameterized test to cover both empty lists and single-element lists of dates, ensuring that insufficient dates are correctly validated and raise a ValueError.
| @pytest.mark.asyncio | |
| @pytest.mark.parametrize("dates", [[], ["2024-09-23"]]) | |
| async def test_fetch_cabinet_flow_insufficient_dates(organisation_service, dates): | |
| async def test_fetch_cabinet_flow_single_date_fails(organisation_service): | |
| president_id = "pres1" | |
| dates = ["2024-09-23"] | |
| with pytest.raises(ValueError): | |
| await organisation_service.fetch_cabinet_flow(president_id, dates) | |
| @pytest.mark.asyncio | |
| @pytest.mark.parametrize('dates', [[], ['2024-09-23']]) | |
| async def test_fetch_cabinet_flow_insufficient_dates(organisation_service, dates): | |
| president_id = 'pres1' | |
| with pytest.raises(ValueError): | |
| await organisation_service.fetch_cabinet_flow(president_id, dates) |
…abinet-flow"
This reverts commit 5432299, reversing changes made to 292e59b.