Triple-T / gradle-play-publisher

GPP is Android's unofficial release automation Gradle Plugin. It can do anything from building, uploading, and then promoting your App Bundle or APK to publishing app listings and other metadata.
MIT License
4.1k stars 340 forks source link

403 due to previously used version code leads to successful build #995

Closed crysxd closed 3 years ago

crysxd commented 3 years ago

Describe the bug

I had an issue with my version code causing a old version code which already was uploaded to Google Play to be used again. I know from making a similar mistake some time ago that this caused the build to fail and a error response from the Google Play API to be shown in the logs. Now (versions below) this does not cause the build to fail for me and the 403 error is only shown in builds with --debug set.

How To Reproduce

Versions

(Same issue with AGP+gradle 7 and the matching 3.5.0-agp7)

Tasks executed

publishReleaseBundle

Expected behavior

Build fails after 403

Additional context (if a crash, provide stack trace)

This build did not upload anything (because same version code)

> Task :app:signReleaseBundle
> Task :app:publishReleaseBundle
Starting App Bundle upload: /builds/crysxd/octoapp/app/build/outputs/bundle/release/app-release.aab
Uploading App Bundle: 85% complete
Ignoring artifact (/builds/crysxd/octoapp/app/build/outputs/bundle/release/app-release.aab)
> Task :commitEditForDeDotCrysxdDotOctoapp
Committing changes
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.8.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 5m 53s
218 actionable tasks: 217 executed, 1 up-to-date

Same tag with --debug

2021-08-16T14:33:50.101+0200 [LIFECYCLE] [class org.gradle.internal.buildevents.TaskExecutionLogger] > Task :app:publishReleaseBundle
2021-08-16T14:34:29.916+0200 [DEBUG] [sun.net.www.protocol.http.HttpURLConnection] sun.net.www.MessageHeader@2392ec5b10 pairs: {null: HTTP/1.1 403 Forbidden}{X-GUploader-UploadID: ADPycduet-sLUt9ylZC5fHUGu8yIwIf2kNGl0d9lCW4o7tM8DDaew5z1zAYdMmhOLmctX2UlxRxX5yHRAmlSHpyy_5M0yQP2ZQ}{Vary: Origin}{Vary: X-Origin}{Vary: Referer}{Content-Type: application/json; charset=UTF-8}{Content-Length: 323}{Date: Mon, 16 Aug 2021 12:34:29 GMT}{Server: UploadServer}{Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"}
2021-08-16T14:34:29.917+0200 [INFO] [com.google.api.client.http.HttpTransport] -------------- RESPONSE --------------
HTTP/1.1 403 Forbidden
Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
Server: UploadServer
X-GUploader-UploadID: ADPycduet-(redacted)
Vary: Referer
Vary: X-Origin
Vary: Origin
Content-Length: 323
Date: Mon, 16 Aug 2021 12:34:29 GMT
Content-Type: application/json; charset=UTF-8

2021-08-16T14:34:29.918+0200 [INFO] [com.google.api.client.http.HttpTransport] Total: 323 bytes
2021-08-16T14:34:29.918+0200 [INFO] [com.google.api.client.http.HttpTransport] {
  "error": {
    "code": 403,
    "message": "APK specifies a version code that has already been used.",
    "errors": [
      {
        "message": "APK specifies a version code that has already been used.",
        "domain": "global",
        "reason": "forbidden"
      }
    ],
    "status": "PERMISSION_DENIED"
  }
}

2021-08-16T14:34:29.919+0200 [WARN] [com.github.triplet.gradle.androidpublisher.EditManager] Ignoring artifact (/Users/christian/Projects/OctoApp/app/build/outputs/bundle/release/app-release.aab)
...
2021-08-16T14:34:29.931+0200 [LIFECYCLE] [class org.gradle.internal.buildevents.TaskExecutionLogger] 
2021-08-16T14:34:29.931+0200 [LIFECYCLE] [class org.gradle.internal.buildevents.TaskExecutionLogger] > Task :commitEditForDeDotCrysxdDotOctoapp
...
2021-08-16T14:34:29.937+0200 [INFO] [com.google.api.client.http.HttpTransport] -------------- REQUEST  --------------
POST https://androidpublisher.googleapis.com/androidpublisher/v3/applications/(redacted)/edits/(redacted):commit
Accept-Encoding: gzip
Authorization: <Not Logged>
User-Agent: gradle-play-publisher Google-API-Java-Client/1.31.5 Google-HTTP-Java-Client/1.39.2 (gzip)
x-goog-api-client: gl-java/13.0.1 gdcl/1.31.5 mac-os-x/10.16
Content-Encoding: gzip

2021-08-16T14:34:29.938+0200 [INFO] [com.google.api.client.http.HttpTransport] curl -v --compressed -X POST -H 'Accept-Encoding: gzip' -H 'Authorization: <Not Logged>' -H 'User-Agent: gradle-play-publisher Google-API-Java-Client/1.31.5 Google-HTTP-Java-Client/1.39.2 (gzip)' -H 'x-goog-api-client: gl-java/13.0.1 gdcl/1.31.5 mac-os-x/10.16' -H 'Content-Encoding: gzip' -d '@-' -- 'https://androidpublisher.googleapis.com/androidpublisher/v3/applications/(redacted)/edits/04269371721395900223:commit' << $$$
2021-08-16T14:34:29.940+0200 [DEBUG] [sun.net.www.protocol.http.HttpURLConnection] sun.net.www.MessageHeader@4690dbc711 pairs: {POST /androidpublisher/v3/applications/(redacted)/edits/04269371721395900223:commit HTTP/1.1: null}{Accept-Encoding: gzip}{Authorization: Bearer (redacted)}{User-Agent: gradle-play-publisher Google-API-Java-Client/1.31.5 Google-HTTP-Java-Client/1.39.2 (gzip)}{x-goog-api-client: gl-java/13.0.1 gdcl/1.31.5 mac-os-x/10.16}{Content-Encoding: gzip}{Host: androidpublisher.googleapis.com}{Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2}{Connection: keep-alive}{Content-type: application/x-www-form-urlencoded}{Transfer-Encoding: chunked}
2021-08-16T14:34:31.347+0200 [DEBUG] [sun.net.www.protocol.http.HttpURLConnection] sun.net.www.MessageHeader@42af57cd14 pairs: {null: HTTP/1.1 200 OK}{Content-Type: application/json; charset=UTF-8}{Vary: Origin}{Vary: X-Origin}{Vary: Referer}{Content-Encoding: gzip}{Date: Mon, 16 Aug 2021 12:34:31 GMT}{Server: ESF}{Cache-Control: private}{X-XSS-Protection: 0}{X-Frame-Options: SAMEORIGIN}{X-Content-Type-Options: nosniff}{Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"}{Transfer-Encoding: chunked}
2021-08-16T14:34:31.348+0200 [INFO] [com.google.api.client.http.HttpTransport] -------------- RESPONSE --------------
HTTP/1.1 200 OK
Transfer-Encoding: chunked
X-Frame-Options: SAMEORIGIN
Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
Cache-Control: private
Server: ESF
X-Content-Type-Options: nosniff
Content-Encoding: gzip
Vary: Referer
Vary: X-Origin
Vary: Origin
X-XSS-Protection: 0
Date: Mon, 16 Aug 2021 12:34:31 GMT
Content-Type: application/json; charset=UTF-8

2021-08-16T14:34:31.348+0200 [INFO] [com.google.api.client.http.HttpTransport] Total: 72 bytes
2021-08-16T14:34:31.348+0200 [INFO] [com.google.api.client.http.HttpTransport] {
  "id": "04269371721395900223",
  "expiryTimeSeconds": "1629124423"
}

...
2021-08-16T14:34:31.450+0200 [LIFECYCLE] [org.gradle.internal.buildevents.BuildResultLogger] 
2021-08-16T14:34:31.450+0200 [LIFECYCLE] [org.gradle.internal.buildevents.BuildResultLogger] BUILD SUCCESSFUL in 5m 59s
2021-08-16T14:34:31.451+0200 [LIFECYCLE] [org.gradle.internal.buildevents.TaskExecutionStatisticsReporter] 228 actionable tasks: 227 executed, 1 up-to-date
...

I replaced sensitive data with (redacted), please note the Bearer token was logged once

SUPERCILEX commented 3 years ago

Are you using auto resolution? If not, when you run the command a second time with --debug, the version code will have been used up from the time it succeeded without --debug. You'll have to bump the version code between builds.

crysxd commented 3 years ago

I found a stray resolutionStrategy.set(ResolutionStrategy.IGNORE) 🙈Thanks for the hint!