Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto validate jsonconverter objects #3890

Conversation

KYash03
Copy link

@KYash03 KYash03 commented Feb 18, 2025

Closes #3885

@CLA-Mercedes-Benz
Copy link

CLA-Mercedes-Benz commented Feb 18, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@lorriborri lorriborri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @KYash03,

Well done and thank you very much for your hard work on this pull request. ⭐
We truly appreciate the effort you've put into it! However, I found some smaller issues that need to be addressed before we can proceed.

First of all, we follow a specific branch naming pattern. Could you please rename your branch to:
feature-3885-auto-validate-jsonconverter-objects

For the other issues, please see my comments!

Once these issues are addressed, we can move forward with the merge. Please let me know if you have any questions or need further clarification.

(Small hint: to avoid a red pipeline because of formatting issues run ./gradlew spotlessApply before a commit.)

Thank you again for your valuable contributions!

Best regards,
Laura

((JSONValidatable) result).validate();
} catch (JSONValidationException e) {
throw new JSONConverterException("Validation failed for " + clazz.getSimpleName(), e);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a generic catch block to catch any unsuspected exceptions that might occur during the validation process (e.g. an unsuspected null pointer).
e.g. Something like:

Suggested change
}
}
catch (Exception e){
throw new JSONConverterException("Could not validate result for " + clazz.getSimpleName(), e);
}

/**
* Exception thrown when JSON validation fails
*/
public class JSONValidationException extends SecHubRuntimeException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to extend the SecHubRuntimeException here, RuntimeException is fine

Suggested change
public class JSONValidationException extends SecHubRuntimeException {
public class JSONValidationException extends RuntimeException {

@KYash03
Copy link
Author

KYash03 commented Feb 26, 2025

New PR: #3938

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Auto validate JSONConverter objects
3 participants