kytos-ng / kytos

Kytos SDN Platform. Kytos is designed to be easy to install, use, develop and share Network Apps (NApps).
https://kytos-ng.github.io/
MIT License
2 stars 7 forks source link

feat: introduced `api_traceback_on_500` kytos config option #380

Closed viniarck closed 1 year ago

viniarck commented 1 year ago

Closes #379

This PR is on top of PR #375

Summary

See updated changelog file (also check out the issue description for more information why this is being introduced).

Local Tests

❯ http http://localhost:8181/api/kytos/of_lldp/v1/polling_time
HTTP/1.1 500 Internal Server Error
content-length: 1570
content-type: text/plain; charset=utf-8
date: Tue, 02 May 2023 13:42:28 GMT
server: uvicorn

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/elasticapm/contrib/starlette/__init__.py", line 173, in __call__
    await self.app(scope, _receive, wrapped_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 66, in app
    response = await func(request)
  File "/home/viniarck/repos/napps2/napps/kytos/of_lldp/main.py", line 621, in get_time
    a
NameError: name 'a' is not defined
❯ http http://localhost:8181/api/kytos/of_lldp/v1/polling_time
HTTP/1.1 500 Internal Server Error
content-length: 21
content-type: text/plain; charset=utf-8
date: Tue, 02 May 2023 13:43:11 GMT
server: uvicorn

Internal Server Error

For both cases though, the traceback will always be in the logs, so the main benefit is really also that the traceback is included in the response, which has demonstrated to be very helpful for e2e tests too.

End-to-End Tests

Not necessary in this case