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

Embed fields such as author icon are considered non-optional #747

Closed
marvin-roesch opened this issue Jul 27, 2020 · 4 comments · Fixed by #749
Closed

Embed fields such as author icon are considered non-optional #747

marvin-roesch opened this issue Jul 27, 2020 · 4 comments · Fixed by #749
Labels
area/core Related to core module: events, entities, clients, specs bug A general bug
Milestone

Comments

@marvin-roesch
Copy link

I have encountered a bug in Discord4J that appears to have been introduced with the upgrade to 3.1.0. Namely, it concerns (to my knowledge) embeds and their properties:

To Reproduce:

  • Generate a message with an embed without e.g. author icon
  • Read that message using Discord4J and look at the embed

Expected Behavior:

  • Embed.Author#getIconUrl returns an empty Optional<String>, null or similar

Actual Behavior:

  • A java.util.NoSuchElementException exception is thrown

Version: 3.1.0

Other: I've only come across the issue with the author icon out in the wild so far, but I'd expect more fields to actually be optional.

@darichey
Copy link
Member

There's a few Possible::get() uses in Embed that were overlooked. Ideally they would've been mapped to Optional and the return types would be changed. Not sure what the best course of action is here since 3.1 is released.

@darichey
Copy link
Member

quanticc pointed out we can annotate these methods as @Nullable and change the implementation to fallback to null. While we generally try to avoid that in core, I think it's the best option here until 3.2. That was the previous behavior anyways, we just didn't know.

@quanticc quanticc added area/core Related to core module: events, entities, clients, specs bug A general bug labels Jul 27, 2020
@quanticc quanticc added this to Backlog in Discord4J v3.0 - v3.1 via automation Jul 27, 2020
@quanticc quanticc added this to the 3.1.1 milestone Jul 27, 2020
@darichey darichey linked a pull request Jul 27, 2020 that will close this issue
@darichey
Copy link
Member

Will be fixed in 3.1.1 with the @Nullable solution and with some incompatible Optional changes in 3.2. If you need the fix before release, you can use a snapshot of either branch.

Discord4J v3.0 - v3.1 automation moved this from Backlog to Done Jul 29, 2020
@marvin-roesch
Copy link
Author

Thanks for the speedy solution @darichey! I've worked around the issue for now by manually catching the exception and mapping it to null (which is fine by me, as I'm using it from Kotlin, anyway), so looking forward to the fixed version!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/core Related to core module: events, entities, clients, specs bug A general bug
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

3 participants