Skip to content

Fix NPE when application password response is missing password or UUID#22952

Draft
adalpari wants to merge 1 commit into
release/26.8from
fix/application-password-null-fields-crash
Draft

Fix NPE when application password response is missing password or UUID#22952
adalpari wants to merge 1 commit into
release/26.8from
fix/application-password-null-fields-crash

Conversation

@adalpari

@adalpari adalpari commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes a crash when the WordPress.com / WP-API application password endpoint returns a 200 response that is missing the password or uuid field.

ApplicationPasswordCreationResponse declared its fields as non-null, but Gson populates objects via reflection and bypasses Kotlin's null-safety. When the field is absent/null in the JSON, the value flowed into the non-null ApplicationPasswordCreationPayload constructor and threw an NPE. In the minified release build the parameter null-check compiles to a bare getClass() call, which is exactly the reported crash signature.

Fix

  • Made uuid, name, and password on ApplicationPasswordCreationResponse nullable to match what Gson can actually produce.
  • Validate the fields on the success path; when either password or uuid is missing, return the existing error payload ("Password or UUID missing from response") instead of crashing. The result propagates as a normal ApplicationPasswordCreationResult.Failure — the same path used for other creation errors.
  • Applied to both JetpackApplicationPasswordsRestClient (where the crash was reported) and WPApiApplicationPasswordsRestClient, which share the response type.

Tests

Added unit tests for both clients covering: valid response, null password, null uuid, null body, and network error.

Crash report

https://a8c.sentry.io/issues/7522022287/?environment=prod&environment=release&project=5731682&query=release%3A%22com.jetpack.android%4026.8-rc-5%2B1493%22&referrer=release-issue-stream

Reported on com.jetpack.android@26.8-rc-5+1493.

🤖 Generated with Claude Code

@dangermattic

Copy link
Copy Markdown
Collaborator
1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

@adalpari adalpari changed the base branch from trunk to release/26.8 June 8, 2026 14:13
The Gson-deserialized ApplicationPasswordCreationResponse declared its
fields as non-null, but Gson populates objects via reflection and bypasses
Kotlin's null checks. When the API returns a 200 response missing the
`password` or `uuid` field, those nulls flowed into the non-null
ApplicationPasswordCreationPayload constructor, crashing the app (in the
minified release build the parameter null-check compiles to a bare
getClass() call, producing the reported NPE).

Make the response fields nullable and validate them, returning the existing
error payload instead of crashing. Applied to both the Jetpack and WP-API
clients, which share the response type.

Crash report: https://a8c.sentry.io/issues/7522022287/

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@adalpari adalpari force-pushed the fix/application-password-null-fields-crash branch from dda20c6 to 0da0911 Compare June 8, 2026 14:14
@wpmobilebot

Copy link
Copy Markdown
Contributor

App Icon📲 You can test the changes from this Pull Request in WordPress Android by scanning the QR code below to install the corresponding build.

App NameWordPress Android
Build TypeDebug
Versionpr22952-0da0911
Build Number1493
Application IDorg.wordpress.android.prealpha
Commit0da0911
Installation URL4e7vl47vgsq8o
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

Copy link
Copy Markdown
Contributor

App Icon📲 You can test the changes from this Pull Request in Jetpack Android by scanning the QR code below to install the corresponding build.

App NameJetpack Android
Build TypeDebug
Versionpr22952-0da0911
Build Number1493
Application IDcom.jetpack.android.prealpha
Commit0da0911
Installation URL52v3k10gi3q20
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

Copy link
Copy Markdown
Contributor

🤖 Build Failure Analysis

This build has failures. Claude has analyzed them - check the build annotations for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants