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

Cannot parse JSON into SlackEventWrapper for many events #128

Open
lightbody opened this issue Dec 31, 2019 · 2 comments
Open

Cannot parse JSON into SlackEventWrapper for many events #128

lightbody opened this issue Dec 31, 2019 · 2 comments
Labels
backlog A good idea, but not one we're planning on implementing in the near future bug Something isn't working

Comments

@lightbody
Copy link
Contributor

This is similar to issue #52, which was resolved but seems to still be a problem for me. Specifically, I am trying to parse an incoming event action like so:

objectMapper.readValue(request.getBody(String.class).get(), SlackEventWrapper.class)

For some events, like a message, it works wonderfully. But for others, where there is no ts field, I get this error from Jackson:

Cannot construct instance of `com.hubspot.slack.client.models.events.SlackEventSkeleton`, problem: Cannot build SlackEventSkeleton, some of required attributes are not set [ts]

I would love to use all the event models that are built up in this project, as I'm already using the web API and it's working great, but this is a bit of a showstopper for me. Any ideas how to work around it?

Thank you for the great project!

@szabowexler szabowexler added the bug Something isn't working label Jan 8, 2020
@szabowexler
Copy link
Collaborator

I suspect you may have fixed this for yourself :)

If that's the case, want to close this issue out?

If not, I think the answer here is that we need to adjust the class hierarchy to ensure that things that don't have a referenced message (like e.g. an app event) don't inherit the exact same fields via the same class hierarchy as message events.

@lightbody
Copy link
Contributor Author

Just a quick update on this: I fixed this specifically for the app_home_opened event... by creating a SlackAppHomeOpenedEvent event (issue #129). But more generally, my code simply can never parse the event wrappers intoSlackEventWrapper if there isn't a specific event class mapped in SlackEventType enum.

I agree that there is something wrong with the class hierarchy. There have been a number of issues along the way related to ts, which seems to be the offended issue. But the fix to this is a bit out of my reach out at the moment. Either way, I need new event classes for app_uninstalled, tokens_revoked, and dnd_updated so I'm going to keep working around this the same way I did for app_home_opened. The only weird thing is that app_uninstalled has no body, so my patch for that one probably should get some extra scrutiny :)

@szabowexler szabowexler added the backlog A good idea, but not one we're planning on implementing in the near future label Jan 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog A good idea, but not one we're planning on implementing in the near future bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants