Uninett / zino

Zino 2.0 - Network state monitor for research networks
Apache License 2.0
3 stars 4 forks source link

Fix strange bug in translation of caseids to Event objects in API commands #163

Closed lunkwill42 closed 5 months ago

lunkwill42 commented 5 months ago

A magic decorator is used to allow API command responders that operate on Events to have its caseid argument automatically translated to a proper Event object. The decorator also ensures the command responder is never run if the incoming caseid is non-existent.

However, there was a slight bug in the error handler: Command responders are async functions. Async functions are always awaitable (i.e. they return Future objects). When the caseid is non-existent, the decorator would return a plain value, None in most cases, which is not awaitable. This would result in strange tracebacks in the logs, and also an additional "500 internal error" line being output to API clients (after the initial 500 message about the invalid caseid).

This was found by running a legacy client against the Zino 2 API implementation. Regression tests are added.

sonarcloud[bot] commented 5 months ago

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

github-actions[bot] commented 5 months ago

Test results

    3 files      3 suites   25s :stopwatch: 247 tests 247 :heavy_check_mark: 0 :zzz: 0 :x: 741 runs  739 :heavy_check_mark: 2 :zzz: 0 :x:

Results for commit b4460351.