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

Bad Request error on getApkDetails when using .aab instead of .apk #2188

Closed
sakurov opened this issue Nov 29, 2021 · 1 comment · Fixed by #2189
Closed

Bad Request error on getApkDetails when using .aab instead of .apk #2188

sakurov opened this issue Nov 29, 2021 · 1 comment · Fixed by #2189
Labels

Comments

@sakurov
Copy link

sakurov commented Nov 29, 2021

Describe the bug
I have a GitLab pipeline with Android Instrumentation tests run by Flank.
Starting from Flank version 21.07.0 I have this error in my GitLab pipeline:

400 Bad Request
POST https://testing.googleapis.com/v1/applicationDetailService/getApkDetails
{
  "code": 400,
  "errors": [
    {
      "domain": "global",
      "message": "Request contains an invalid argument.",
      "reason": "badRequest"
    }
  ],
  "message": "Request contains an invalid argument.",
  "status": "INVALID_ARGUMENT"
}
Full stack trace:
com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
POST https://testing.googleapis.com/v1/applicationDetailService/getApkDetails
{
  "code": 400,
  "errors": [
    {
      "domain": "global",
      "message": "Request contains an invalid argument.",
      "reason": "badRequest"
    }
  ],
  "message": "Request contains an invalid argument.",
  "status": "INVALID_ARGUMENT"
}
 at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:146)
 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$1.interceptResponse(AbstractGoogleClientRequest.java:428)
 at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1111)
 at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:514)
 at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:455)
 at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:565)
 at ftl.client.google.AppDetailsKt.getAndroidAppDetails(AppDetails.kt:7)
 at ftl.run.platform.RunAndroidTestsKt.reportPackageName(RunAndroidTests.kt:101)
 at ftl.run.platform.RunAndroidTestsKt.access$reportPackageName(RunAndroidTests.kt:1)
 at ftl.run.platform.RunAndroidTestsKt$runAndroidTests$2.invokeSuspend(RunAndroidTests.kt:54)
 at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
 at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:33)
 at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
 at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
 at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
 at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:274)
 at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
 at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
 at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
 at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
 at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
 at ftl.domain.RunTestAndroidKt.invoke(RunTestAndroid.kt:66)
 at ftl.presentation.cli.firebase.test.android.AndroidRunCommand.run(AndroidRunCommand.kt:54)
 at picocli.CommandLine.executeUserObject(CommandLine.java:1939)
 at picocli.CommandLine.access$1300(CommandLine.java:145)
 at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2352)
 at picocli.CommandLine$RunLast.handle(CommandLine.java:2346)
 at picocli.CommandLine$RunLast.handle(CommandLine.java:2311)
 at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
 at picocli.CommandLine.execute(CommandLine.java:2078)
 at ftl.Main$main$1.invoke(Main.kt:12)
 at ftl.Main$main$1.invoke(Main.kt:10)
 at ftl.run.exception.ExceptionHandlerKt.withGlobalExceptionHandling(ExceptionHandler.kt:28)
 at ftl.run.exception.ExceptionHandlerKt.withGlobalExceptionHandling(ExceptionHandler.kt:17)
 at ftl.Main.main(Main.kt:10)

After investigation I found out that getApkDetails expects gcsPath to .apk file to be sent, but Flank is supporting .aab as well and I'm using it.
There is a link to getApkDetails documentation - getApkDetails
And there is a link to FileReference object documentation - FileReference. In example we can see .apk file.

To Reproduce
Preconditions:

  • Flank version 21.07.0 or higher
  • app attribute in flank.yml contains path to .aab file
flank.yml example
gcloud:
  app: ${APP_AAB}
  test: ${ANDROID_TEST_APK}
  use-orchestrator: true
  auto-google-login: true
  record-video: true
  timeout: 30m
  type: instrumentation
  num-flaky-test-attempts: 2
  environment-variables:
    clearPackageData: true
  device:
    # Google Pixel 5e (physical)
    - model: redfin
      version: 30
      locale: en_GB
      orientation: portrait
flank:
  shard-time: 180
  default-test-time: 15
  max-test-shards: 20
  run-timeout: 60m

APP_AAB contains local path to .aab
ANDROID_TEST_APK contains local path to Android Test .apk

  1. Run java -jar ./flank.jar firebase test android run
  2. See error
  3. Test Matrix is not created, tests are not running

Expected behavior
Error is not appearing
Test Matrix is created, tests are running

Details
It wasn't checked on the latest snapshot, but due to changes between it and version 21.11.0, I believe that the issue will be reproducible there.

Issue is reproducible on versions:

  • 21.07.0
  • 21.07.1
  • 21.08.1
  • 21.11.0

Issue is not reproducible on versions:

  • 21.05.0
  • 21.06.1

Other versions weren't tested.

If I replace my .aab file by .apk file in the flank.yml - issue disappears, so looks like it is a root cause.

@sakurov sakurov added the Bug label Nov 29, 2021
@bootstraponline
Copy link
Contributor

Thanks for reporting! I agree this is a bug.

We should skip this API call for aab files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants