wordpress-mobile / wordpress-mobile/GutenbergKit
Editor fails to load when a cached capability flag is stale
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29
- Forks
- 6
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 41
Description
Description
When a host caches a site capability (shouldUseThemeStyles/themeStyles, shouldUsePlugins/plugins) and the site later loses the backing REST route, the editor fails to load with an error instead of degrading to the default experience.
The 404 is a definitive, correct answer — the route does not exist — and it's the same answer route discovery would have given had it re-run. Both platforms already have a supported "capability absent" value (EditorSettings.undefined, LocalEditorAssetManifest.empty), so this should resolve to that value rather than surfacing as an error.
The user-facing message is also WordPress's raw REST string, which is a separate problem affecting every editor load failure.
Steps to reproduce
- Activate the Gutenberg plugin on a test site
- Open the site's Editor Configuration in the Demo app — Supports Theme Styles should be ✅
- Deactivate the Gutenberg plugin
- Open the editor
Expected: editor loads with default editor styles.
Actual: an error view.
iOS: Editor Error — No route was found matching the URL and request method.
Android: Failed to load editor — rest_no_route: No route was found matching the URL and request method.
| iOS | Android |
|---|---|
Cause
Identical on both platforms:
- Host caches the capability as
true; the site changes underneath it without re-running discovery fetchEditorSettingsno longer short-circuits and issues the request — iOSRESTAPIRepository.swift#L93-L97, AndroidRESTAPIRepository.kt#L88-L91- WordPress returns 404
rest_no_route; the client throws a WP-error type - Nothing treats it as recoverable, so it propagates out of
prepare() - The library's own error view renders the exception message
Proposed fix
Treat 404 rest_no_route on an optional dependency as the capability being absent:
- iOS:
RESTAPIRepository.fetchEditorSettings()→.undefined - iOS:
EditorAssetLibrary.fetchManifest()→LocalEditorAssetManifest.empty - Android:
RESTAPIRepository.fetchEditorSettings()→EditorSettings.undefined - Android:
EditorAssetsLibrary.fetchManifest()→LocalEditorAssetManifest.empty
Each of these already returns exactly that value when its capability flag is false — iOS settings, iOS manifest, Android settings, Android manifest. The fix extends the same outcome to the case where the endpoint itself reports the capability absent.
Scope the guard to rest_no_route specifically so genuine 404s elsewhere (e.g. a missing post) stay fatal.
This must not respect any network-fallback policy. A 404 is a successful round-trip carrying an authoritative answer; reachability policy is irrelevant. Gating it would leave hosts with fallback disabled (and all Android hosts) hitting this same wall.
Notes
- Not demo-only. WP-Android's
EditorCapabilityResolverpersists capabilities across sessions — a wider staleness window than the iOS demo's per-session one. WP-iOS is likewise affected. - Applies equally to
/wpcom/v2/editor-assetsand the plugins capability. - The iOS demo's offline config deliberately sets both capabilities
trueoptimistically (SitePreparationView.swift#L334-L342, from #366). That's safe while offline, but if connectivity returns mid-session the flags are stale in exactly this way. This fix makes that optimism safe unconditionally. - Impact data:
wpios_gutenberg_kit_editor_load_failed/jpios_gutenberg_kit_editor_load_failedrun ~5–20/day sustained. Segment bywordpress_error_code = rest_no_routeto size this specific path. iOS-only — WP-Android has no equivalent instrumentation, so real impact is undercounted. - Surfaced while reviewing #600; unrelated to those changes.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read the four repository and asset-library entry points linked in the issue: iOS and Android RESTAPIRepository files plus EditorAssetLibrary.swift and EditorAssetsLibrary.kt. Reproduce the stale-capability scenario by disabling Gutenberg after capability discovery, then verify that both platforms load the default editor experience for rest_no_route while other 404 errors remain fatal.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin, swift, wordpress
- Domain
- api, mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 65/100