镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Data.isNull return invalid true after proguard #2603

Open

Description

@miguelangellv

Environment details

  1. Kotlin Multiplatform Project
  2. Compose Multiplatform
  3. Youtube API

Steps to reproduce

  1. Configure Youtube API
  2. Create request a videos list using setMine(true)
  3. Apply proguard/r8
  4. Get error

Code example

// example

Stack trace


Field: mine , value: true, isNull: true
Field: part, value [contentDetails], isNull: false

Generated URL: https://youtube.googleapis.com/youtube/v3/channels?part=contentDetails


Exception in thread "AWT-EventQueue-0" com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
GET https://youtube.googleapis.com/youtube/v3/channels?part=contentDetails
{
  "code": 400,
  "errors": [
    {
      "domain": "youtube.parameter",
      "location": "parameters.",
      "locationType": "other",
      "message": "No filter selected. Expected one of: mySubscribers, forUsername, forHandle, categoryId, id, mine, managedByMe",
      "reason": "missingRequiredParameter"
    }
  ],
  "message": "No filter selected. Expected one of: mySubscribers, forUsername, forHandle, categoryId, id, mine, managedByMe"
}
	at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:145)
	at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:118)
	at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:37)
	at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$3.interceptResponse(AbstractGoogleClientRequest.java:479)
	at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1111)
	at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:565)
	at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:506)
	at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:616)
	at org.malv.youtube.services.YoutubeService$getVideos$2.invokeSuspend(YoutubeService.kt:49)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100)
	at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:124)
	at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:89)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:586)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:1820)
	Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@38fc853c, Dispatchers.Main.immediate]


External references such as API reference guides

isNull method

public static boolean isNull(Object object) { // don't call nullOf because will throw IllegalArgumentException if cannot create instance 
   return object != null && object == NULL_CACHE.get(object.getClass()); 
}

Any additional information below

I think the problem is that, after ProGuard, Boolean object is converted to primitives, so, "true" are the same object in NULL_CACHE and it return isNull. If the value is "false" return that is not null.

Activity

  1. diegomarquezp commented on Sep 8, 2025

    @diegomarquezp
    Contributor

    Hi @miguelangellv, thanks for reporting this issue and the steps to reproduce. Would you mind enhancing your reproduction steps by providing a simple snippet or project to demonstrate the failure?

    Additionally, the error proposes a missing filter field. How are you setting this in your code?

    Also, please note that for fast response times, you can refer to our Support Hub if you have a support plan with Google Cloud.

  2. added
    type: questionRequest for information or clarification. Not an issue.
    priority: p3Desirable enhancement or fix. May not be included in next release.
    on Sep 8, 2025
  3. miguelangellv commented on Sep 8, 2025

    @miguelangellv
    Author

    A simple way to check if:

    if (Data.NULL_BOOLEAN === true)
         println("Equals: Proguard")
    else
         println("Not equals, no proguard")

    I set the filter with:

            val channels = youtube.channels()
                .list(listOf("contentDetails"))
                .setMine(true) // This value
                .execute()
                .items

    My actual workaround is a horrible fix but it works...

        fun init {
            runCatching {
                val dataClass = Class.forName("com.google.api.client.util.Data")
                val nullCacheField: Field = dataClass.getDeclaredField("NULL_CACHE")
                nullCacheField.isAccessible = true
                val nullCache = nullCacheField.get(null) as ConcurrentHashMap<*, *>
                nullCache.clear()
            }
        }
  4. added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    and removed
    type: questionRequest for information or clarification. Not an issue.
    on Oct 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p3Desirable enhancement or fix. May not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions