bcgov / bcgov/wps

HFI Calculator: 500 error reported by user

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

Description

We received an email saying the user was experiencing errors when using HFI Calculator. Here's the screenshot they sent:

![image.png](https://images.zenhubusercontent.com/6375312161f086155789c147/847d6465-1339-49b7-a1fa-6648ba4e6cd3)

We did not see the error and HFI Calc was working as expected for us when we investigated at ~10:30am May 29.[Uploading... wps-prod-242-4ws4w-wps-api.log]

I've attached a log file that might be helpful. Here's a couple entries that might be relevant:

2023-05-25 18:22:55,749 - app.routers.fba_calc - CRITICAL - Failed to calculate ROS
Traceback (most recent call last):
File "/app/app/routers/fba_calc.py", line 243, in get_stations_data
station_response = await process_request(
File "/app/app/routers/fba_calc.py", line 161, in process_request
fire_behaviour_advisory = calculate_fire_behaviour_advisory(fba_station)
File "/app/app/fire_behaviour/advisory.py", line 101, in calculate_fire_behaviour_advisory
ros = cffdrs.rate_of_spread(station.fuel_type, isi=station.isi, bui=station.bui, fmc=fmc, sfc=sfc,
File "/app/app/fire_behaviour/cffdrs.py", line 381, in rate_of_spread
raise CFFDRSException("Failed to calculate ROS")

and this one looks like an issue with the WF1 API

2023-05-25 18:49:36,729 - app.routers.fba_calc - CRITICAL - '_embedded'
Traceback (most recent call last):
File "/app/app/routers/fba_calc.py", line 213, in get_stations_data
dailies_by_station_id = {raw_daily.get('stationId'): raw_daily async for raw_daily in dailies}
File "/app/app/routers/fba_calc.py", line 213, in
dailies_by_station_id = {raw_daily.get('stationId'): raw_daily async for raw_daily in dailies}
File "/app/app/wildfire_one/wildfire_fetchers.py", line 92, in fetch_paged_response_generator
for response_object in response_json['_embedded'][content_key]:
KeyError: '_embedded'
2023-05-25 18:49:36,730 - app.main - ERROR - POST /api/fba-calc/stations '_embedded'
Traceback (most recent call last):
File "/home/worker/.cache/pypoetry/virtualenvs/wps-api-9TtSrW0h-py3.10/lib/python3.10/site-packages/anyio/streams/memory.py", line 94, in receive
return self.receive_nowait()
File "/home/worker/.cache/pypoetry/virtualenvs/wps-api-9TtSrW0h-py3.10/lib/python3.10/site-packages/anyio/streams/memory.py", line 89, in receive_nowait
raise WouldBlock
anyio.WouldBlock

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/worker/.cache/pypoetry/virtualenvs/wps-api-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/base.py", line 78, in call_next
message = await recv_stream.receive()
File "/home/worker/.cache/pypoetry/virtualenvs/wps-api-9TtSrW0h-py3.10/lib/python3.10/site-packages/anyio/streams/memory.py", line 114, in receive
raise EndOfStream
anyio.EndOfStream

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/app/app/main.py", line 86, in catch_exception_middleware
return await call_next(request)
File "/home/worker/.cache/pypoetry/virtualenvs/wps-api-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/base.py", line 84, in call_next
raise app_exc
File "/home/worker/.cache/pypoetry/virtualenvs/wps-api-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/base.py", line 70, in coro
await self.app(scope, receive_or_disconnect, send_no_error)
File "/home/worker/.cache/pypoetry/virtualenvs/wps-api-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/cors.py", line 92, in __call__
await self.simple_response(scope, receive, send, request_headers=headers)
File "/home/worker/.cache/pypoetry/virtualenvs/wps-api-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/cors.py", line 147, in simple_response
await self.app(scope, receive, send)
File "/home/worker/.cache/pypoetry/virtualenvs/wps-api-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
raise exc
File "/home/worker/.cache/pypoetry/virtualenvs/wps-api-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
await self.app(scope, receive, sender)
File "/home/worker/.cache/pypoetry/virtualenvs/wps-api-9TtSrW0h-py3.10/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
raise e
File "/home/worker/.cache/pypoetry/virtualenvs/wps-api-9TtSrW0h-py3.10/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
await self.app(scope, receive, send)
File "/home/worker/.cache/pypoetry/virtualenvs/wps-api-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/routing.py", line 718, in __call__
await route.handle(scope, receive, send)
File "/home/worker/.cache/pypoetry/virtualenvs/wps-api-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/routing.py", line 276, in handle
await self.app(scope, receive, send)
File "/home/worker/.cache/pypoetry/virtualenvs/wps-api-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/routing.py", line 66, in app
response = await func(request)
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/fba_calc.py", line 213, in get_stations_data
dailies_by_station_id = {raw_daily.get('stationId'): raw_daily async for raw_daily in dailies}
File "/app/app/routers/fba_calc.py", line 213, in
dailies_by_station_id = {raw_daily.get('stationId'): raw_daily async for raw_daily in dailies}
File "/app/app/wildfire_one/wildfire_fetchers.py", line 92, in fetch_paged_response_generator
for response_object in response_json['_embedded'][content_key]:
KeyError: '_embedded'

Contributor guide

Open the contributing guide

Research direction

Start in app/routers/fba_calc.py at get_stations_data and process_request, then trace app/wildfire_one/wildfire_fetchers.py:92 and app/fire_behaviour/advisory.py:101. Use the attached log entries to investigate both the missing '_embedded' response and the failed ROS calculation. Done means identifying and resolving the cause of the HFI Calculator 500 error paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
fastapi, python
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.