You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When introducing profiles in Policies, the respective schema was updated accordingly. However, this did not take under consideration the fact that pre-existing policies would have a null value for this column instead of an empty collection.
So, while querying the DB for policies, a NPE is launched, breaking its use.
To Reproduce
Deploying a new instance in an infrastructure containing (stored) policies built before the addition of the profiles property. Simply retrieve (GET all, for example) policies and a 500 HTTP error will likely be seen.
Expected behavior
Backwards compatible with previous structure. Aim could be to have a default profiles value of an empty collection. Avoiding a null would be needed.
Screenshots/Error Messages
Used version: 0.8.0 of Tractus-X
Possible Implementation
An implementation with a couple of steps may solve this.
First, create an update values in table edc_policydefinitions in migrations to ensure not null existing values, similar to:
UPDATE edc_policydefinitions SET profiles='[]'::json where profiles is NULL;
Also, ensure programmatically that this condition happens, in order to avoid the NPE. A possible suggestion would be on the Upstream repo, having a validation before calling the Policy.Builder.
The text was updated successfully, but these errors were encountered:
this was my fault, definitely, anyway curious that this has been spotted only now, the migration has been there for more than 4 months ("having release that's not deployed anywhere is like not having a release").
We could add a note in the 0.8.0 release and in the migration guide as a suggestion to workaround this problem, then provide the fix for the 0.8.1 version.
EDIT:
Also, ensure programmatically that this condition happens, in order to avoid the NPE. A possible suggestion would be on the Upstream repo, having a validation before calling the Policy.Builder.
to be honest I'm not too in favor of having this handled programmatically, because null and empty array are two different values and they need to be handled in different ways.
in this case, null is inconsistent data for this column, so the NPE is totally doing its job, and the fix must happen in the data.
I guess this (as with most of other more trivial issues that should had been caught already) happens because adopters only start deploying after the version is officially released. I.e., no one keeps a deployed version of the main branch of tractusx-edc...
Describe the bug
When introducing profiles in Policies, the respective schema was updated accordingly. However, this did not take under consideration the fact that pre-existing policies would have a
null
value for this column instead of an empty collection.So, while querying the DB for policies, a
NPE
is launched, breaking its use.To Reproduce
Deploying a new instance in an infrastructure containing (stored) policies built before the addition of the
profiles
property. Simply retrieve (GET all, for example) policies and a500
HTTP error will likely be seen.Expected behavior
Backwards compatible with previous structure. Aim could be to have a default
profiles
value of an empty collection. Avoiding a null would be needed.Screenshots/Error Messages
Possible Implementation
An implementation with a couple of steps may solve this.
First, create an update values in table
edc_policydefinitions
in migrations to ensure not null existing values, similar to:Also, ensure programmatically that this condition happens, in order to avoid the
NPE
. A possible suggestion would be on the Upstream repo, having a validation before calling thePolicy.Builder
.The text was updated successfully, but these errors were encountered: