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

Add NEUTRAL as a valid RecommendationType #1098

Merged
merged 1 commit into from Oct 8, 2020

Conversation

jfposton
Copy link
Contributor

@jfposton jfposton commented Oct 8, 2020

I have started noticing that some of my Facebook Page ratings stream messages have a recommendation_type of 'NEUTRAL'. The corresponding enum (RecommendationType) does not include NEUTRAL as one of the valid values for this field which is preventing me from processing these events since a parsing error is thrown.

Here is an example JSON snippet and the stack trace I get with the identifying information removed:

Event

{"value":{"created_time":1602179746,"item":"rating","open_graph_story_id":"123","review_text":"Review text goes here.","recommendation_type":"NEUTRAL","reviewer_id":"1234","reviewer_name":"Reviewer","verb":"add"},"field":"ratings"}

Stack Trace

com.restfb.exception.FacebookJsonMappingException: Unable to map JSON to Java. Offending JSON is '{"value":{"created_time":1602179746,"item":"rating","open_graph_story_id":"123","review_text":"Review text goes here.","recommendation_type":"NEUTRAL","reviewer_id":"1234","reviewer_name":"Reviewer","verb":"add"},"field":"ratings"}'.
        at com.restfb.DefaultJsonMapper.toJavaObject(DefaultJsonMapper.java:251) ~[dep-plugin-facebook-cdf5a183-d7c4-49cf-89b7-b0ffd84e95e1.jar.1602173437000:?]
        at com.restfb.DefaultJsonMapper.toJavaList(DefaultJsonMapper.java:138) ~[dep-plugin-facebook-cdf5a183-d7c4-49cf-89b7-b0ffd84e95e1.jar.1602173437000:?]
        at com.restfb.DefaultJsonMapper.toJavaType(DefaultJsonMapper.java:638) ~[dep-plugin-facebook-cdf5a183-d7c4-49cf-89b7-b0ffd84e95e1.jar.1602173437000:?]
        at com.restfb.DefaultJsonMapper.toJavaObject(DefaultJsonMapper.java:233) ~[dep-plugin-facebook-cdf5a183-d7c4-49cf-89b7-b0ffd84e95e1.jar.1602173437000:?]
        at com.restfb.DefaultJsonMapper.toJavaList(DefaultJsonMapper.java:138) ~[dep-plugin-facebook-cdf5a183-d7c4-49cf-89b7-b0ffd84e95e1.jar.1602173437000:?]
        at com.restfb.DefaultJsonMapper.toJavaType(DefaultJsonMapper.java:638) ~[dep-plugin-facebook-cdf5a183-d7c4-49cf-89b7-b0ffd84e95e1.jar.1602173437000:?]
        at com.restfb.DefaultJsonMapper.toJavaObject(DefaultJsonMapper.java:233) ~[dep-plugin-facebook-cdf5a183-d7c4-49cf-89b7-b0ffd84e95e1.jar.1602173437000:?]
         ....<omitted>...
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.GeneratedMethodAccessor65.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_202]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_202]
        at com.restfb.DefaultJsonMapper.invokeJsonMappingCompletedMethods(DefaultJsonMapper.java:286) ~[dep-plugin-facebook-cdf5a183-d7c4-49cf-89b7-b0ffd84e95e1.jar.1602173437000:?]
        at com.restfb.DefaultJsonMapper.toJavaObject(DefaultJsonMapper.java:245) ~[dep-plugin-facebook-cdf5a183-d7c4-49cf-89b7-b0ffd84e95e1.jar.1602173437000:?]
        ... 18 more
Caused by: com.restfb.exception.FacebookJsonMappingException: Don't know how to map JSON to class com.restfb.types.RecommendationType. Are you sure you're mapping to the right class?
Offending JSON is 'NEUTRAL'.
        at com.restfb.DefaultJsonMapper.toPrimitiveJavaType(DefaultJsonMapper.java:549) ~[dep-plugin-facebook-cdf5a183-d7c4-49cf-89b7-b0ffd84e95e1.jar.1602173437000:?]
        at com.restfb.DefaultJsonMapper.toJavaObject(DefaultJsonMapper.java:180) ~[dep-plugin-facebook-cdf5a183-d7c4-49cf-89b7-b0ffd84e95e1.jar.1602173437000:?]
        at com.restfb.DefaultJsonMapper.toJavaType(DefaultJsonMapper.java:696) ~[dep-plugin-facebook-cdf5a183-d7c4-49cf-89b7-b0ffd84e95e1.jar.1602173437000:?]
        at com.restfb.DefaultJsonMapper.toJavaObject(DefaultJsonMapper.java:233) ~[dep-plugin-facebook-cdf5a183-d7c4-49cf-89b7-b0ffd84e95e1.jar.1602173437000:?]
        at com.restfb.types.webhook.ChangeValueFactory.buildWithMapper(ChangeValueFactory.java:99) ~[dep-plugin-facebook-cdf5a183-d7c4-49cf-89b7-b0ffd84e95e1.jar.1602173437000:?]
        at com.restfb.types.webhook.Change.convertChangeValue(Change.java:57) ~[dep-plugin-facebook-cdf5a183-d7c4-49cf-89b7-b0ffd84e95e1.jar.1602173437000:?]
        at sun.reflect.GeneratedMethodAccessor65.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_202]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_202]
        at com.restfb.DefaultJsonMapper.invokeJsonMappingCompletedMethods(DefaultJsonMapper.java:286) ~[dep-plugin-facebook-cdf5a183-d7c4-49cf-89b7-b0ffd84e95e1.jar.1602173437000:?]
        at com.restfb.DefaultJsonMapper.toJavaObject(DefaultJsonMapper.java:245) ~[dep-plugin-facebook-cdf5a183-d7c4-49cf-89b7-b0ffd84e95e1.jar.1602173437000:?]
        ... 18 more

I have been receiving rating webhook messages that include a recommendation_type value of 'NEUTRAL'. Without this being a value in the RecommendationType enum I am unable to parse this.
@nbartels nbartels self-assigned this Oct 8, 2020
@nbartels
Copy link
Contributor

nbartels commented Oct 8, 2020

hm, would be interesting to see how this looks like on the Facebook page...

many thanks for the PR

@nbartels nbartels added this to the 3.11.0 milestone Oct 8, 2020
@jfposton jfposton marked this pull request as ready for review October 8, 2020 21:37
@nbartels nbartels merged commit 7fc018b into restfb:dev Oct 8, 2020
@jfposton
Copy link
Contributor Author

jfposton commented Oct 9, 2020

Thanks for the quick response! Do you have an idea when 3.11 will be released?

@nbartels
Copy link
Contributor

nbartels commented Oct 9, 2020

Yes, I have. I pushed the release just now and it should be available on maven central soon.

@jfposton
Copy link
Contributor Author

jfposton commented Oct 9, 2020

That's great news. Thanks!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants