wordpress-mobile / wordpress-mobile/GutenbergKit

bug(demo-android): PostEndpointType.Custom receives slug instead of restBase

Open
#442 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29
Forks
6
Avg merge
1d 9h
Merged PRs (30d)
41

Description

Context

In PR #433 (feat/demo-edit-existing-posts), the Android demo app maps PostTypeDetails to PostEndpointType for REST API calls. The mapping for custom post types passes the wrong value.

Bug

In both EditorActivity.persistPost() and PostsListActivity.loadPosts(), the else branch passes postType.postType (the slug, e.g. "product") to PostEndpointType.Custom():

else -> PostEndpointType.Custom(configuration.postType.postType)  // slug: "product"

However, PostEndpointType.Custom expects a restBase value (e.g. "products"), which is used directly as a URL path segment (/wp/v2/<value>/<id>). This is confirmed by the wordpress-rs source where PostEndpointType::Custom uses strum Display to serialize the inner string verbatim into the URL path.

The iOS demo correctly passes restBase:

endpointType = .custom(configuration.postType.restBase)  // restBase: "products"

Impact

For any custom post type where slug ≠ restBase (the common case, e.g. slug "product" vs restBase "products"), Android will construct URLs like /wp/v2/product/123 instead of /wp/v2/products/123, resulting in rest_no_route errors on both save and list operations.

Fix

Change postType.postType to postType.restBase in both locations:

  • EditorActivity.kt (~line 361)
  • PostsListActivity.kt (~line 181)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect the custom post type mapping in EditorActivity.kt around line 361 and PostsListActivity.kt around line 181. Compare the Android mapping with the iOS demo and verify that both save and list requests use restBase, producing the correct WordPress REST URL for custom post types.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
api, mobile
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.