eclipse / kapua

Eclipse Public License 2.0
222 stars 160 forks source link

:bug: [REST API] Fix `ServiceConfigurations` to return `KapuaIllegalArgument` instead of `204` #4064

Closed MDeLuise closed 1 month ago

MDeLuise commented 2 months ago

Description

The ServiceConfigurations class methods (update, getComponent, updateComponent) currently return 204 or null when the following check is not true:

if (KapuaConfigurableService.class.isAssignableFrom(configurableServiceClass)) {
   ...
}

This behavior does not appropriately handle invalid user-provided values.

Solution

This pull request updates the methods in ServiceConfigurations to throw a KapuaIllegalArgument exception when appropiate.

codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 0% with 19 lines in your changes missing coverage. Please review.

Project coverage is 16.81%. Comparing base (2349705) to head (c090c8a).

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/eclipse/kapua/pull/4064/graphs/tree.svg?width=650&height=150&src=pr&token=1P4N4CApH8&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse)](https://app.codecov.io/gh/eclipse/kapua/pull/4064?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse) ```diff @@ Coverage Diff @@ ## develop #4064 +/- ## ============================================= - Coverage 16.81% 16.81% -0.01% Complexity 22 22 ============================================= Files 2008 2008 Lines 52164 52167 +3 Branches 4398 4398 ============================================= Hits 8770 8770 - Misses 42998 43001 +3 Partials 396 396 ``` | [Files](https://app.codecov.io/gh/eclipse/kapua/pull/4064?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse) | Coverage Δ | | |---|---|---| | [.../resources/v1/resources/ServiceConfigurations.java](https://app.codecov.io/gh/eclipse/kapua/pull/4064?src=pr&el=tree&filepath=rest-api%2Fresources%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Fapp%2Fapi%2Fresources%2Fv1%2Fresources%2FServiceConfigurations.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-cmVzdC1hcGkvcmVzb3VyY2VzL3NyYy9tYWluL2phdmEvb3JnL2VjbGlwc2Uva2FwdWEvYXBwL2FwaS9yZXNvdXJjZXMvdjEvcmVzb3VyY2VzL1NlcnZpY2VDb25maWd1cmF0aW9ucy5qYXZh) | `0.00% <0.00%> (ø)` | |