firebase / firebase-android-sdk

Firebase Android SDK
https://firebase.google.com
Apache License 2.0
2.28k stars 578 forks source link

Cannot access 'val data: Any?': it is private in 'com/google/firebase/functions/HttpsCallableResult' #6522

Open thatfiredev opened 1 week ago

thatfiredev commented 1 week ago

[REQUIRED] Step 2: Describe your environment

[REQUIRED] Step 3: Describe the problem

Functions SDK version 21.1.0 seems to have broken source compatibility. Specifically when using HttpsCallableResult:

Version 21.0.0

suspend fun addMessage(text: String) {
    val data = hashMapOf("text" to text)

    val result = functions
        .getHttpsCallable("addMessage")
        .call(data)
        .await()

    val data = result?.data // <-- WORKS
}

Version 21.1.0

suspend fun addMessage(text: String) {
    val data = hashMapOf("text" to text)

    val result = functions
        .getHttpsCallable("addMessage")
        .call(data)
        .await()

    val data = result?.data // <-- Cannot access 'val data: Any?': it is private in 'com/google/firebase/functions/HttpsCallableResult'
}

Spotted in https://github.com/firebase/quickstart-android/actions/runs/11883012926/job/33109208274

emilypgoogle commented 6 days ago

This seems to be related to how Kotlin coerces Java's functions into field accesses. A java function called foo.getData() can be accessed as foo.data from Kotlin. However, if the code is compiled from Kotlin, you need to explicitly provide the getters. The released changes for Functions should be binary compatible but as shown, not source compatible for Kotlin consumers. This shouldn't affect Java users. Existing tooling doesn't exist to make sure this isn't broken and only focused on Java compatibility. The fix is both fixing this specific case and checking the rest of the SDK for instances where the conversion may have caused this, which I'll work on for the next Firebase release.