Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Comments

Avoid Index out of bounds in ButtonWidgetConfigureActivitty#6096

Merged
TimoPtr merged 1 commit intomainfrom
fix/avoid_index_out_of_bounds_button_widget
Nov 26, 2025
Merged

Avoid Index out of bounds in ButtonWidgetConfigureActivitty#6096
TimoPtr merged 1 commit intomainfrom
fix/avoid_index_out_of_bounds_button_widget

Conversation

@TimoPtr
Copy link
Member

@TimoPtr TimoPtr commented Nov 25, 2025

Summary

We have crashes on production about the ButtonWidgetConfigureActivitty when splitting the action text.

Exception java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
  at java.util.Collections$SingletonList.get (Collections.java:5260)
  at io.homeassistant.companion.android.widgets.button.ButtonWidgetConfigureActivity.getPendingDaoEntity (ButtonWidgetConfigureActivity.kt:393)
  at io.homeassistant.companion.android.widgets.BaseWidgetConfigureActivity.updateWidget (BaseWidgetConfigureActivity.kt:161)
  at io.homeassistant.companion.android.widgets.button.ButtonWidgetConfigureActivity.access$updateWidget (ButtonWidgetConfigureActivity.kt:53)
  at io.homeassistant.companion.android.widgets.button.ButtonWidgetConfigureActivity$onCreate$5$2.invokeSuspend (ButtonWidgetConfigureActivity.kt:373)
  at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:34)
  at kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith (DispatchedContinuation.kt:375)
  at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable (Cancellable.kt:26)
  at kotlinx.coroutines.CoroutineStart.invoke (CoroutineStart.kt:358)
  at kotlinx.coroutines.AbstractCoroutine.start (AbstractCoroutine.kt:134)
  at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch (Builders.common.kt:53)
  at kotlinx.coroutines.BuildersKt.launch (Unknown Source:1)
  at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default (Builders.common.kt:44)
  at kotlinx.coroutines.BuildersKt.launch$default (Unknown Source:1)
  at io.homeassistant.companion.android.widgets.button.ButtonWidgetConfigureActivity.onCreate$lambda$2 (ButtonWidgetConfigureActivity.kt:372)
  at io.homeassistant.companion.android.widgets.button.ButtonWidgetConfigureActivity.$r8$lambda$XQggeGtIJJLheo7hNFAbCbfAm4Q (Unknown Source)
  at io.homeassistant.companion.android.widgets.button.ButtonWidgetConfigureActivity$$ExternalSyntheticLambda3.onClick (D8$$SyntheticClass)
  at android.view.View.performClick (View.java:8055)
  at android.widget.TextView.performClick (TextView.java:17819)
  at android.view.View.performClickInternal (View.java:8032)
  at android.view.View.-$$Nest$mperformClickInternal (Unknown Source)
  at android.view.View$PerformClick.run (View.java:31923)
  at android.os.Handler.handleCallback (Handler.java:958)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loopOnce (Looper.java:230)
  at android.os.Looper.loop (Looper.java:319)
  at android.app.ActivityThread.main (ActivityThread.java:9063)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:588)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1103)

This PR doesn't fix the issue about why it happens but it handle the case where we cannot split the action properly.

@jpelgrom
Copy link
Member

Is this exception occurring for a lot of people? It's while reading from the database so it must be writing incorrect data...

Copy link
Member

@jpelgrom jpelgrom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good as a quick fix, even if it means the widget is already unusable

@TimoPtr
Copy link
Member Author

TimoPtr commented Nov 26, 2025

It's impacting 232 users on the Play Store according to the crashes

@TimoPtr
Copy link
Member Author

TimoPtr commented Nov 26, 2025

I was able to reproduce the issue by simply using an action without a . in it.

@TimoPtr TimoPtr merged commit 24c76a1 into main Nov 26, 2025
22 checks passed
@TimoPtr TimoPtr deleted the fix/avoid_index_out_of_bounds_button_widget branch November 26, 2025 08:42
@jpelgrom
Copy link
Member

I was able to reproduce the issue by simply using an action without a . in it.

HA doesn't natively have actions like that though? It's always domain.action.

@TimoPtr
Copy link
Member Author

TimoPtr commented Nov 26, 2025

I was able to reproduce the issue by simply using an action without a . in it.

HA doesn't natively have actions like that though? It's always domain.action.

I hope so. But we were not making any verification so if you were entering manually something wrong it was crashing.

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.

2 participants