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

Include property name when serialization fails #300

Merged
merged 2 commits into from
Aug 26, 2019

Conversation

aguibert
Copy link
Member

@aguibert aguibert commented Aug 9, 2019

Fixes #297

I added an error message that includes:

  • The property name that failed to serialize
  • The name of the class containing the property we were trying to serialize
  • The toString() value of the property we were trying to serialize.

@m0mus / @Verdent I am not sure whether or not it is safe to be including the property value in the error message. For example, it could be an extremely large value (e.g. byte array). Also, are there any security reasons why we have not included property values in error messages in the past?

EDIT: nvm, decided to not include property value in error messages

@aguibert aguibert requested review from Verdent and m0mus August 9, 2019 19:37
@aguibert aguibert self-assigned this Aug 9, 2019
@nimo23
Copy link

nimo23 commented Aug 10, 2019

the property value in the error message

In my opinion, no! Don't put the property value in the error message. It is sufficient to put only the property name (with class name) in the error message! It would also be a security risk to add the value in the log..

@aguibert
Copy link
Member Author

yea I think you're right @nimo23, it could be a security risk, or the value could be very large.

As long as Yasson says what property/class is failing to serialize, then the developer should be able to add print statements to determine the value if necessary.

@aguibert aguibert changed the title Include property name/value when serialization fails Include property namewhen serialization fails Aug 11, 2019
@aguibert aguibert changed the title Include property namewhen serialization fails Include property name when serialization fails Aug 11, 2019
@aguibert
Copy link
Member Author

@m0mus or @Verdent can one of you please review?


import javax.json.bind.JsonbException;

public class Assertions {
Copy link
Member

@Verdent Verdent Aug 21, 2019

Choose a reason for hiding this comment

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

@aguibert I am thinking about updating JUnit to version 5 instead of adding this class. As far as I know JUnit 5 could be able to handle this. What do you think? It might be some work to do, but I would say it is worth it. (I am not saying that you should update it by yourself.)

Copy link
Member Author

Choose a reason for hiding this comment

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

@Verdent yea I'm all for JUnit 5, it's actually what inspired this helper class for now. Lets handle that separately from this PR though.
I assume you have no other objections to this PR and it's good to merge?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I would say it looks good.

@aguibert aguibert merged commit 126a109 into eclipse-ee4j:master Aug 26, 2019
@aguibert aguibert added this to the 1.0.5 milestone Sep 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include property name that failed to serialize in error messages
3 participants