Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException: autoCreateLinks(...) must not be null #20758

Open
sentry-io bot opened this issue May 2, 2024 · 4 comments
Open

NullPointerException: autoCreateLinks(...) must not be null #20758

sentry-io bot opened this issue May 2, 2024 · 4 comments
Assignees
Labels
Gutenberg Editing and display of Gutenberg blocks. Posting/Editing [Type] Crash

Comments

@sentry-io
Copy link

sentry-io bot commented May 2, 2024

Sentry Issue: JETPACK-ANDROID-R4R

RuntimeException: Unable to start activity ComponentInfo{com.jetpack.android/org.wordpress.android.ui.posts.EditPostActivity}: java.lang.NullPointerException: autoCreateLinks(...) must not be null
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3946)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4126)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:108)
    at android.app.servertransaction.TransactionExecutor.executeNonLifecycleItem(TransactionExecutor.java:195)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:157)
...
(9 additional frame(s) were not displayed)

NullPointerException: autoCreateLinks(...) must not be null
    at org.wordpress.android.ui.posts.EditPostActivity.newPostFromShareAction(EditPostActivity.kt:451)
    val content = migrateToGutenbergEditor(AutolinkUtils.autoCreateLinks(text))
    at org.wordpress.android.ui.posts.EditPostActivity.handleIntentExtras(EditPostActivity.kt:665)
    newPostFromShareAction()
    at org.wordpress.android.ui.posts.EditPostActivity.onCreate(EditPostActivity.kt:533)
    handleIntentExtras(intent.extras, isRestarting)
...
(15 additional frame(s) were not displayed)
@dangermattic
Copy link
Collaborator

dangermattic commented May 2, 2024

Thanks for reporting! 👍

@thomashorta thomashorta added Gutenberg Editing and display of Gutenberg blocks. Posting/Editing labels May 2, 2024
@thomashorta
Copy link
Contributor

It doesn't seem that this was in-fact introduced in 24.8, but there was recent code refactoring the EditPostActivity to Kotlin which caused this new crash signature when the text passed to autoCreateLinks is null, I believe.

@zwarm since you probably know more about this context and the Kotlin conversion, I am assigning you to the crash, but feel free to assign to someone else if it makes sense.

I did a quick investigation and it looks like the issue is that autoCreateLinks can return null, but it's not marked as @Nullable, so the Kotlin code doesn't complain in compilation time and crashes in that scenario in runtime.

I believe we need to properly handle the case of text or autoCreateLinks being null to avoid this crash.

@zwarm
Copy link
Contributor

zwarm commented May 3, 2024

@thomashorta - Exactly. In the java class only the first use of autoCreateLinks was checking for nulls before usage, the second use of the method was not. I am raising a PR against release/24.8 to check for nulls and if so, then send empty text instead. The jave code would have also crashed because it did not prevent nulls from being passed along. :(

Copy link
Author

sentry-io bot commented May 9, 2024

Sentry Issue: WORDPRESS-ANDROID-2YCN

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Gutenberg Editing and display of Gutenberg blocks. Posting/Editing [Type] Crash
Projects
None yet
Development

No branches or pull requests

3 participants