SORMAS-Project icon indicating copy to clipboard operation
SORMAS-Project copied to clipboard

[#4959] switch from @ Required to @ NotNull

Open JonasCir opened this issue 3 years ago • 6 comments

Closes #4959 Closes #4937

So I tested it with the fix for #4937 (which I included here in this PR as well). The API returns 400 bad request now :tada:

JonasCir avatar Mar 30 '21 13:03 JonasCir

@MateStrysewske removed the special casing for Required from the swagger generation. Ready for review :)

JonasCir avatar Apr 01 '21 07:04 JonasCir

@JonasCir Looks fine to me, however I'm a bit concerned about this potentially breaking a) the mobile app synchronisation and b) external systems. Have you tried creating cases, contacts, samples, events, etc. in the mobile app and syncing them to the backend? If not, please do so.

@vidi42 @FredrikSchaeferVitagroup @HolgerReiseVSys @leventegal-she Do you see any potential problems with this in terms of external systems?

MateStrysewske avatar Apr 01 '21 11:04 MateStrysewske

@MateStrysewske I will take another testing pass, I absolutely understand that this change is critical. Also we are not in a rush to merge this therefore we should take our time and wait for feedback :)

JonasCir avatar Apr 01 '21 11:04 JonasCir

I just tried to create a new case via processing a labMessage. When clicking of Save, I get an exception:

 (1) Kind: PROPERTY
 message: darf nicht null sein
 root bean: de.symeda.sormas.backend.contact.ContactFacadeEjb@59e65e07
 property path: saveContact.arg0.lastContactDate

FredrikSchaefer avatar Apr 01 '21 13:04 FredrikSchaefer

As also VisitDto was modified, and I don't now what values the external journals consider not nullable, this has the potential to break the communication with external journals. We should maybe communicate this change and test quite extensively before rolling this out to production?

FredrikSchaefer avatar Apr 01 '21 13:04 FredrikSchaefer

Alright, the thing here is that the annotation where just cosmetic before, therefore, we need to figure out which values are really "required". In the past I came along fields which were required to be not null by the logic, but weren't annotated as such. In the same way, there are values which are not required but were erroneously marked as such.

JonasCir avatar Apr 01 '21 14:04 JonasCir

@MateStrysewske @MateStrysewske @StefanKock I rebased this branch. I really think we should get rid of @Required as it is effectively useless, a source of confusion, and a steady source of bugs over the years.

JonasCir avatar Mar 16 '23 11:03 JonasCir

Most of the current test failures are likely caused by the fact that things were marked as required, but never truly were.

JonasCir avatar Mar 16 '23 15:03 JonasCir

@JonasCir We can't merge this PR as long as there are test failures though

MateStrysewske avatar Mar 17 '23 09:03 MateStrysewske

Yeah we need to talk this through as I really don't know what of the fields are truly required and which are not

JonasCir avatar Mar 17 '23 11:03 JonasCir

SonarCloud analysis: https://sonarcloud.io/dashboard?id=SORMAS-Project&pullRequest=4961

sormas-vitagroup avatar Apr 05 '23 07:04 sormas-vitagroup

@MateStrysewske All probems are fixed now. Please re-review (or look into the last two commits). I have removed some of the NotNull annotations based on #7648.

MartinWahnschaffe avatar Apr 05 '23 08:04 MartinWahnschaffe

SonarCloud analysis: https://sonarcloud.io/dashboard?id=SORMAS-Project&pullRequest=4961

sormas-vitagroup avatar Apr 05 '23 08:04 sormas-vitagroup

SonarCloud analysis: https://sonarcloud.io/dashboard?id=SORMAS-Project&pullRequest=4961

sormas-vitagroup avatar Apr 05 '23 13:04 sormas-vitagroup

SonarCloud analysis: https://sonarcloud.io/dashboard?id=SORMAS-Project&pullRequest=4961

sormas-vitagroup avatar Apr 05 '23 13:04 sormas-vitagroup

SonarCloud analysis: https://sonarcloud.io/dashboard?id=SORMAS-Project&pullRequest=4961

sormas-vitagroup avatar Apr 06 '23 07:04 sormas-vitagroup