Boavizta / boaviztapi

🛠 Giving access to BOAVIZTA reference data and methodologies trough a RESTful API
GNU Affero General Public License v3.0
66 stars 21 forks source link

Instances referencing non existing "platform_aws_m1" platform, leads to 500 error / #286

Closed bpetit closed 2 months ago

bpetit commented 2 months ago

Bug description

"platform_aws_m1" is referenced by instances .m1. in aws.csv, but this platform doesn't exist in server.csv

Querying those instances on cloud/instance route leads to 500 error and this trace in the API :

'NoneType' object is not subscriptable Traceback (most recent call last): File "/app/boaviztapi/main.py", line 45, in catch_exceptions_middleware return await call_next(request) File "/usr/local/lib/python3.9/site-packages/starlette/middleware/base.py", line 84, in call_next raise app_exc File "/usr/local/lib/python3.9/site-packages/starlette/middleware/base.py", line 70, in coro await self.app(scope, receive_or_disconnect, send_no_error) File "/usr/local/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 79, in call raise exc File "/usr/local/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 68, in call await self.app(scope, receive, sender) File "/usr/local/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in call raise e File "/usr/local/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in call await self.app(scope, receive, send) File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 718, in call await route.handle(scope, receive, send) File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 276, in handle await self.app(scope, receive, send) File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 66, in app response = await func(request) File "/usr/local/lib/python3.9/site-packages/fastapi/routing.py", line 237, in app raw_response = await run_endpoint_function( File "/usr/local/lib/python3.9/site-packages/fastapi/routing.py", line 163, in run_endpoint_function return await dependant.call(**values) File "/app/boaviztapi/routers/cloud_router.py", line 48, in instance_cloud_impact instance_model = mapper_cloud_instance(cloud_instance, archetype=instance_archetype) File "/app/boaviztapi/dto/device/device.py", line 82, in mapper_cloud_instance complete_components_usage(model_cloud_instance.platform, model_cloud_instance.usage) File "/app/boaviztapi/dto/device/device.py", line 59, in complete_components_usage for disk_unit in model.disk: File "/app/boaviztapi/model/device/server.py", line 53, in disk if get_arch_component(self.archetype, "SSD")["units"] not in [{}, {'default':0}]: TypeError: 'NoneType' object is not subscriptable

To Reproduce

Query one of those instances on cloud/instance route : db.m1.medium, m1.medium, db.m1.small, m1.small, db.m1.large, m1.large, db.m1.xlarge

Expected behavior

200 OK with impacts result

bpetit commented 2 months ago

Closing the issue as we sumed up all missing servers issues in #284