play-console-cli icon indicating copy to clipboard operation
play-console-cli copied to clipboard

deobfuscation upload --type nativeCode fails: API rejects lowercased 'nativecode'

Open adriandleon opened this issue 4 months ago • 0 comments

Summary

gplay deobfuscation upload --type nativeCode always fails with a 400 from the Play API, because the CLI lowercases the type for validation but then reuses the lowercased value to build the actual API call.

Reproduction

gplay deobfuscation upload \
  --package <pkg> \
  --edit <edit-id> \
  --apk-version <version-code> \
  --file native-debug-symbols.zip \
  --type nativeCode

Result:

Error: failed to upload deobfuscation file: googleapi: Error 400: Invalid value at 'deobfuscation_file_type' (type.googleapis.com/google.play.publishingapi.v3.DeobfuscationFileType), "nativecode"
Details:
[
  {
    "@type": "type.googleapis.com/google.rpc.BadRequest",
    "fieldViolations": [
      {
        "description": "Invalid value at 'deobfuscation_file_type' (type.googleapis.com/google.play.publishingapi.v3.DeobfuscationFileType), \"nativecode\"",
        "field": "deobfuscation_file_type"
      }
    ]
  }
]

--type proguard works fine since "proguard" is already all-lowercase.

Root cause

In internal/cli/deobfuscation/deobfuscation.go:

// Validate deobfuscation type
deobType := strings.ToLower(strings.TrimSpace(*deobfuscationType))
if deobType != "proguard" && deobType != "nativecode" {
    return fmt.Errorf("--type must be 'proguard' or 'nativeCode'")
}
...
call := service.API.Edits.Deobfuscationfiles.Upload(pkg, *editID, int64(versionCode), deobType)

deobType is lowercased for the validation comparison, then reused as-is to build the API call. The Play Developer API requires the exact camelCase value nativeCode for this path parameter — sending nativecode gets rejected.

Suggested fix

Keep the original-cased value for the API call; only lowercase a local copy for the validation comparison, e.g.:

trimmed := strings.TrimSpace(*deobfuscationType)
normalized := strings.ToLower(trimmed)
if normalized != "proguard" && normalized != "nativecode" {
    return fmt.Errorf("--type must be 'proguard' or 'nativeCode'")
}
apiType := "proguard"
if normalized == "nativecode" {
    apiType = "nativeCode"
}
...
call := service.API.Edits.Deobfuscationfiles.Upload(pkg, *editID, int64(versionCode), apiType)

Environment

  • gplay 0.8.0 (Homebrew, tamtom/tap/gplay), also present on main as of the preflight offline-scanner commit (2026-08-02) — confirmed via diff, no fix has landed.
  • macOS

adriandleon avatar Aug 02 '26 17:08 adriandleon