Skip to content

fix(android): skip preloading a post the server doesn't have - #825

Merged
dcalhoun merged 1 commit into
fix/autofocus-only-new-empty-postsfrom
fix/android-skip-preloading-unsaved-post
Oct 23, 2026
Merged

dcalhoun merged 1 commit into
fix/autofocus-only-new-empty-postsfrom
fix/android-skip-preloading-unsaved-post

Conversation

@dcalhoun

@dcalhoun dcalhoun commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

What?

Disable Android preloading of non-existent posts.

Why?

This doesn't fix an active bug. However, the request would fail. iOS already guarded against/prevented this exact thing.

How?

Rely upon #823's serverPostId to guard the post preloading.

Testing Instructions

Opening existing posts should function as they did before.

Accessibility Testing Instructions

N/A, no user-facing changes.

Screenshots or screencast

N/A, no user-facing changes.


AI-generated details

Android's preload fetched the post for any non-null postId, so a zero or negative ID requested /posts/0 or /posts/-1. The 404 fails EditorService.prepare(), so the editor never loads. The preload now uses serverPostId from #823, which aligns Android with iOS's existing postID > 0 check (EditorService.swift) and with the -1 the web editor receives for a new post.

This is a latent bug, not an active one. No shipping host triggers it: WordPress-Android and the demo app send null for new posts and local drafts, and a real server ID otherwise. #823 does treat (-1L).toUInt() as a new post, though, and without this change that input fails to load.

Testing

  • EditorServiceTest cases for a zero and a negative post ID. The Android library unit tests and Detekt pass.

🤖 Generated with Claude Code

@dcalhoun dcalhoun added the [Type] Bug An existing feature does not function as intended label Oct 23, 2026
@dcalhoun
dcalhoun added this pull request to stack #826 October 23, 2026 15:14
@wpmobilebot

wpmobilebot commented Oct 23, 2026 •

Copy link
Copy Markdown

XCFramework Build

This PR's XCFramework is available for testing. Add the following to your Package.swift:

.package(url: "https://github.com/wordpress-mobile/GutenbergKit", branch: "pr-build/825")

Built from 0c14b1a

The preload fetched any non-null postId, so a zero or negative ID requested /posts/0 or /posts/-1 from the server. It now uses serverPostId, matching iOS's postID > 0 check and the ID the web editor receives.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dcalhoun
dcalhoun force-pushed the fix/android-skip-preloading-unsaved-post branch from a88431e to 0c14b1a Compare October 23, 2026 15:40
@dcalhoun
dcalhoun marked this pull request as ready for review October 23, 2026 15:51
@dcalhoun
dcalhoun requested a review from nbradbury October 23, 2026 15:52

@nbradbury nbradbury left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good! :shipit:

@dcalhoun
dcalhoun merged commit ea2298f into trunk Oct 23, 2026
27 checks passed
@dcalhoun
dcalhoun deleted the fix/android-skip-preloading-unsaved-post branch October 23, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants