wordpress-mobile / wordpress-mobile/WordPress-Android
Site Settings: Categories don't load if there are more than 100
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 3.2k
- Forks
- 1.4k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 69
Description
Expected behavior
Loading the list of categories under Site Settings for sites with a large number of categories should correctly list them.
Actual behavior

It looks like results returned from the API are paginated to 100, but the logic tries to loop through the found value returned by the API response, which is the grand total of categories (> 100 in this case).
This eventually results in a JSON exception Index 100 out of range [0..100) on the 101st iteration (we're not currently logging the exception), and the function returns null as the list of categories.
This is probably a pretty rare occurrence, I doubt many sites have over 100 categories (this occurred for me on a test site that has had hundreds of categories generated from automated tests in the past).
Steps to reproduce the behavior
- Select a WPcom site with over 100 categories
- Visit My Site -> Settings
- Notice that the 'Default category' item doesn't list what the default is
- Tap on 'Default category', and notice that the dialog is blank, like the screenshot above
Tested on Pixel 3, Android 11, WPAndroid 16.9
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
Start in WordPress/src/main/java/org/wordpress/android/ui/prefs/WPComSiteSettings.java at lines 956-963 and inspect how the category API response is iterated. Reproduce with a site containing more than 100 categories; done means the categories load without a JSON exception and the Default category dialog is populated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100