Open viniarck opened 2 years ago
This payload below still results in a crash, id
shouldn't be accepted:
{
"id": 1,
"uni_a": {
"interface_id": "00:00:00:00:00:00:00:02:1"
},
"uni_z": {
"interface_id": "00:00:00:00:00:00:00:03:1"
}
}
Traceback (most recent call last):
File "/home/viniarck/repos/kytos/.direnv/python-3.9.16/lib/python3.9/site-packages/starlette/middleware/errors.py", line 162, in __call__
await self.app(scope, receive, _send)
File "/home/viniarck/repos/kytos/.direnv/python-3.9.16/lib/python3.9/site-packages/starlette/middleware/cors.py", line 84, in __call__
await self.app(scope, receive, send)
File "/home/viniarck/repos/kytos/.direnv/python-3.9.16/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
raise exc
File "/home/viniarck/repos/kytos/.direnv/python-3.9.16/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
await self.app(scope, receive, sender)
File "/home/viniarck/repos/kytos/.direnv/python-3.9.16/lib/python3.9/site-packages/starlette/routing.py", line 716, in __call__
await route.handle(scope, receive, send)
File "/home/viniarck/repos/kytos/.direnv/python-3.9.16/lib/python3.9/site-packages/starlette/routing.py", line 276, in handle
await self.app(scope, receive, send)
File "/home/viniarck/repos/kytos/.direnv/python-3.9.16/lib/python3.9/site-packages/starlette/routing.py", line 68, in app
response = await run_in_threadpool(func, request)
File "/home/viniarck/repos/kytos/.direnv/python-3.9.16/lib/python3.9/site-packages/starlette/concurrency.py", line 41, in run_in_threadpool
return await anyio.to_thread.run_sync(func, *args)
File "/home/viniarck/repos/kytos/.direnv/python-3.9.16/lib/python3.9/site-packages/anyio/to_thread.py", line 31, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "/home/viniarck/repos/kytos/.direnv/python-3.9.16/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread
return await future
File "/home/viniarck/repos/kytos/.direnv/python-3.9.16/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 867, in run
result = context.run(func, *args)
File "/home/viniarck/repos/kytos/kytos/core/helpers.py", line 459, in wrapper_validate
return func(*args, **kwargs)
File "/home/viniarck/repos/napps/napps/kytos/mef_eline/main.py", line 342, in update
enable, redeploy = evc.update(
File "/home/viniarck/repos/napps/napps/kytos/mef_eline/models/evc.py", line 218, in update
setattr(self, attribute, value)
AttributeError: can't set attribute
I tried to reproduce this error with no success. Maybe it was solve with a previous PR.
@Alopalao it's still crashing, create an EVC and try to update with this payload:
{
"id": 1,
"uni_a": {
"interface_id": "00:00:00:00:00:00:00:02:1"
},
"uni_z": {
"interface_id": "00:00:00:00:00:00:00:03:1"
}
}
2024-06-14 15:25:27,401 - INFO [uvicorn.access] (MainThread) 127.0.0.1:43644 - "GET /api/kytos/mef_eline/v2/evc/ HTTP/1.1" 200
2024-06-14 15:25:50,809 - INFO [uvicorn.access] (MainThread) 127.0.0.1:39930 - "PATCH /api/kytos/mef_eline/v2/evc/259133d27c6c4c HTTP/1.1" 500
2024-06-14 15:25:50,809 - ERROR [uvicorn.error] (MainThread) Exception in ASGI application
Traceback (most recent call last):
File "/home/viniarck/repos/kytos/.direnv/python-3.11/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 419, in run_asgi
result = await app( # type: ignore[func-returns-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/viniarck/repos/kytos/.direnv/python-3.11/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/viniarck/repos/kytos/.direnv/python-3.11/lib/python3.11/site-packages/starlette/applications.py", line 116, in __call__
await self.middleware_stack(scope, receive, send)
File "/home/viniarck/repos/kytos/.direnv/python-3.11/lib/python3.11/site-packages/starlette/middleware/errors.py", line 186, in __call__
raise exc
File "/home/viniarck/repos/kytos/.direnv/python-3.11/lib/python3.11/site-packages/starlette/middleware/errors.py", line 164, in __call__
await self.app(scope, receive, _send)
File "/home/viniarck/repos/kytos/.direnv/python-3.11/lib/python3.11/site-packages/starlette/middleware/cors.py", line 83, in __call__
await self.app(scope, receive, send)
File "/home/viniarck/repos/kytos/.direnv/python-3.11/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
File "/home/viniarck/repos/kytos/.direnv/python-3.11/lib/python3.11/site-packages/starlette/_exception_handler.py", line 55, in wrapped_app
raise exc
File "/home/viniarck/repos/kytos/.direnv/python-3.11/lib/python3.11/site-packages/starlette/_exception_handler.py", line 44, in wrapped_app
await app(scope, receive, sender)
File "/home/viniarck/repos/kytos/.direnv/python-3.11/lib/python3.11/site-packages/starlette/routing.py", line 746, in __call__
await route.handle(scope, receive, send)
File "/home/viniarck/repos/kytos/.direnv/python-3.11/lib/python3.11/site-packages/starlette/routing.py", line 288, in handle
await self.app(scope, receive, send)
File "/home/viniarck/repos/kytos/.direnv/python-3.11/lib/python3.11/site-packages/starlette/routing.py", line 75, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
File "/home/viniarck/repos/kytos/.direnv/python-3.11/lib/python3.11/site-packages/starlette/_exception_handler.py", line 55, in wrapped_app
raise exc
File "/home/viniarck/repos/kytos/.direnv/python-3.11/lib/python3.11/site-packages/starlette/_exception_handler.py", line 44, in wrapped_app
await app(scope, receive, sender)
File "/home/viniarck/repos/kytos/.direnv/python-3.11/lib/python3.11/site-packages/starlette/routing.py", line 72, in app
response = await run_in_threadpool(func, request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/viniarck/repos/kytos/.direnv/python-3.11/lib/python3.11/site-packages/starlette/concurrency.py", line 35, in run_in_threadpool
return await anyio.to_thread.run_sync(func, *args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/viniarck/repos/kytos/.direnv/python-3.11/lib/python3.11/site-packages/anyio/to_thread.py", line 56, in run_sync
return await get_async_backend().run_sync_in_worker_thread(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/viniarck/repos/kytos/.direnv/python-3.11/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 2144, in run_sync_in_worker_thread
return await future
^^^^^^^^^^^^
File "/home/viniarck/repos/kytos/.direnv/python-3.11/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 851, in run
result = context.run(func, *args)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/viniarck/repos/kytos/kytos/core/helpers.py", line 451, in wrapper_validate
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/home/viniarck/repos/napps/napps/kytos/mef_eline/main.py", line 380, in update
enable, redeploy = evc.update(**updated_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/viniarck/repos/napps/napps/kytos/mef_eline/models/evc.py", line 258, in update
setattr(self, attribute, value)
AttributeError: property 'id' of 'EVC' object has no setter
The circuit
id
isn't supposed to be set, and if it's defined in the request body it crashes the server.How to reproduce
Send this payload to
PATCH {{baseUrl}}/api/kytos/mef_eline/v2/evc/{{circuit_id}}