anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: jwstegemann/fritz2
Issue: TypeAhead causes ClassCastException with Popover/Keyup-Events

When using a typeahead on the same page as a popover, selecting an item from a typeAhead causes a ClassCastException, which stops JS Execution on the page.

Here is a minimal example:

    fun main() {
        render(DefaultTheme()) {
            div {
                popover {
                    toggle { div { +"Popover" } }
                    content { div { +"Hello" } }
                }
                typeAhead(value = storeOf(""), items = { flow ->
                        flow.map { (1..50).map { it.toString() } }
                })
            }
        }
    }

After some investigation i found, that the issue is the keyup listener in the Popover. #517 might be a partial solution, but other keyup listeners will still cause an issue.

The problem is, that fritz2 assumes to get a 'KeyboardEvent' from the keyup listener, but in case of selecting an item from a datalist, the event looks different, it neither has 'key' or 'keyCode' properties.

Changed files:
core/src/jsMain/kotlin/dev/fritz2/dom/window.kt

diff --git a/core/src/jsMain/kotlin/dev/fritz2/dom/window.kt b/core/src/jsMain/kotlin/dev/fritz2/dom/window.kt
index 26716941..0f25fbe6 100644
--- a/core/src/jsMain/kotlin/dev/fritz2/dom/window.kt
+++ b/core/src/jsMain/kotlin/dev/fritz2/dom/window.kt
@@ -19,12 +19,17 @@ object Window {
      *
      * @param type [EventType] to listen for
      */
-    private fun <E : Event> subscribe(type: EventType<E>): WindowListener<E> = WindowListener(
+    private inline fun <reified E : Event> subscribe(type: EventType<E>): WindowListener<E> = WindowListener(
         callbackFlow {
             val listener: (Event) -> Unit = {
-                trySend(it.unsafeCast<E>())
+                if (it is E) {
+                    trySend(it.unsafeCast<E>())
+                } else {
+                    console.error("Unexpected type while listening for `${type.name}` events in Window object")
+                }
             }
             browserWindow.addEventListener(type.name, listener)
+
             awaitClose { browserWindow.removeEventListener(type.name, listener) }
         })
Repository: jwstegemann/fritz2
Issue: Repair remote auth middleware - prevent endless loop for 403 response

The default status codes for a failed *authentication* should be reduced to only ``401``.

Currently also the ``403`` code will trigger the ``handleResponse`` interception method and starts a new authentication recursively. This is of course a bad idea, as the *authorization* will not change by the authentication process. Therefore the default http status for launching an authentication process should be only ``401``.

Changed files:
core/src/jsMain/kotlin/dev/fritz2/remote/auth.kt

diff --git a/core/src/jsMain/kotlin/dev/fritz2/remote/auth.kt b/core/src/jsMain/kotlin/dev/fritz2/remote/auth.kt
index df390db0..a150d6e5 100644
--- a/core/src/jsMain/kotlin/dev/fritz2/remote/auth.kt
+++ b/core/src/jsMain/kotlin/dev/fritz2/remote/auth.kt
@@ -45,9 +45,9 @@ abstract class Authentication<P> : Middleware {
 
     /**
      * List of HTTP-Status-Codes forcing an authentication.
-     * Defaults are 401 (unauthorized) and 403 (forbidden).
+     * Default is 401 (unauthorized).
      */
-    open val statusCodesEnforcingAuthentication: Set<Int> = setOf(401, 403)
+    open val statusCodesEnforcingAuthentication: Set<Int> = setOf(401)
 
     /**
      * Adds the authentication information to all requests by using the given [principal].