bcgov / bcgov/wps

MoreCast2: Back-end error when fetching predictions

Open
#3,010 0 comments 0 reactions 0 assignees View on GitHub
Bug
Dominant language
Python
Stars
65
Forks
11
Avg merge
1d 2h
Merged PRs (30d)
70

Description

**Actual Behaviour**

If all the stations within a station group do not have 'actuals' in WF1, we see an error in the backend as follows:

File "/home/worker/.cache/pypoetry/virtualenvs/wps-api-9TtSrW0h-py3.10/lib/python3.10/site-packages/fastapi/routing.py", line 237, in app
raw_response = await run_endpoint_function(
File "/home/worker/.cache/pypoetry/virtualenvs/wps-api-9TtSrW0h-py3.10/lib/python3.10/site-packages/fastapi/routing.py", line 163, in run_endpoint_function
return await dependant.call(**values)
File "/app/app/routers/morecast_v2.py", line 195, in get_determinates_for_date_range
min_wf1_actuals_date = min(wf1_actuals_dates)
ValueError: min() arg is an empty sequence

**Steps To Reproduce**

1. Create a station group that contains a single station that is offline (prod) or for which there is no actual data observed in dev.
2. Load the station group in MoreCast 2.
3. Check the developer console and you will see that the front-end received a 500 error from the back-end.

**Expected Behaviour**

This condition should be handled on the back-end and a proper 200 response returned to the front-end with no 'actuals'.

Contributor guide

Open the contributing guide

Research direction

Start in app/routers/morecast_v2.py at get_determinates_for_date_range, especially the min(wf1_actuals_dates) call at line 195, and reproduce the case with a station group whose station has no WF1 actuals. Done means the endpoint returns HTTP 200 and the front end receives no actuals instead of a backend 500 error.

Written by the indexing model from the issue text.

Assessment

Tech stack
fastapi, python
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.