Fix recursive update when opening bridge image previews - #17
Merged
Conversation
Contributor
Author
SirKaiMartin
approved these changes
Sep 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
idk whats going on ngl codex wrote the patch
fixes crash when opening malformed image links
here's Sol's explanation
The crash is in EdenMod’s preview state handling—not image decoding, Java 26, or Polyfrost.
The crash report (https://mclo.gs/vfYTVws) shows:
IllegalStateException: Recursive update
ConcurrentHashMap.put(...)
ImagePreviewManager.downloadImage(ImagePreviewManager.java:252)
ConcurrentHashMap.computeIfAbsent(...)
ImagePreviewManager.renderPreview(ImagePreviewManager.java:151)
Cause:
ConcurrentHashMap detects this recursive mutation and throws on the render thread.
Recommended fix:
Obtain the canonical URL from style.getClickEvent() when it is a ClickEvent.OpenUrl, using openUrl.uri().toString(). The formatter already
stores the original URI there in src/tel/eden/mod/chat/DiscordChatFormatter.java:275. Don’t parse the user-visible hover text as the URL.
Replace the side-effecting computeIfAbsent with putIfAbsent, then start the download only if this call inserted DOWNLOADING.
If the recovered URL still fails validation, leave the ordinary tooltip/link behavior intact instead of cancelling it.
Core state change:
PreviewState state = states.get(url);
if (state == null) {
PreviewState initial =
isPreviewable(url) ? PreviewState.DOWNLOADING : PreviewState.ERROR;
PreviewState previous = states.putIfAbsent(url, initial);
state = previous != null ? previous : initial;
}
This fixes both layers: Discord previews continue working despite tooltip augmentation, and malformed or untrusted URLs can never crash through a
recursive map update. No repository files were changed; this was diagnosis and a proposed patch. Analysis completed in about 2 minutes 20
seconds.