DEV Community

Yuji Numata
Yuji Numata

Posted on Fully Autonomous

My signing plugin's tests passed. The release bundle was still debug-signed.

My signing plugin had unit tests. They passed. The release bundle it produced was still signed with the Android debug key, and I only found out by accident.

How it happened

A bare Expo project gets its android/ folder from expo prebuild. In that generated build.gradle, the release build type points at the debug signing config. Play Console refuses a debug-signed upload, so you have to change that line. Since expo prebuild --clean throws the folder away, I change it from a config plugin that rewrites the file on every prebuild.

The plugin looked for the old form of the line. Recent React Native templates (I noticed it on 0.81) add an equals sign:

- signingConfig signingConfigs.debug
+ signingConfig = signingConfigs.debug
Enter fullscreen mode Exit fullscreen mode

My regex didn't match, so the plugin quietly did nothing. The build succeeded. My tests fed the plugin a copy of the old template, so they were green too.

How I found it

Someone in the comments on my last post suggested reading the merged manifest after the build, not just app.json. While I was adding that, I ran keytool on the bundle out of curiosity:

keytool -printcert -jarfile android/app/build/outputs/bundle/release/app-release.aab
Enter fullscreen mode Exit fullscreen mode

The owner line said CN=Android Debug, O=Android, C=US.

If you build locally, that command is worth running once. Your own key shows your own name there. If you see Android Debug, Play will reject the file. If you're on a machine with a non-English locale, add -J-Duser.language=en so the labels come out in English.

The manifest check

The second check is the one from the comment. Play reads the manifest after every library has merged its permissions in. After a local release build, that file is here:

android/app/build/intermediates/bundle_manifest/release/processApplicationManifestReleaseForBundle/AndroidManifest.xml
Enter fullscreen mode Exit fullscreen mode

I compare it with package.json. If an ads library is installed, com.google.android.gms.permission.AD_ID has to be in that file, or the Advertising ID answer in Play Console won't match. A billing library needs com.android.vending.BILLING. And the template adds a few you probably don't use, like SYSTEM_ALERT_WINDOW.

A script for both

I put both checks in a small CLI with no dependencies. It needs Node 18+ and a JDK:

npx github:ykisoftware/expo-play-check
Enter fullscreen mode Exit fullscreen mode

It exits 1 when something will bounce, so it can sit in CI. The source is on GitHub under the same name, MIT licensed.

What I took from this: a test that runs on a fixture only proves the fixture. The bundle is the thing Play reads, so now I check the bundle.

I found this while building my Expo starter kit, which runs the same checks after each release build. It's paid and linked from the README. The script works without it.

Top comments (6)

Collapse
 
hyunsoo_xenoci profile image
Hyunsoo Ju •

"A test that runs on a fixture only proves the fixture" is the line I'd put on the wall. A regex config plugin against a template that changes under you is exactly where that bites, and it never fails loudly.

The iOS side of an Expo app has the same trap, so if your starter kit grows an iOS check, the artifact-level version is short. Unzip the .ipa and ask the binary rather than the config:

unzip -q App.ipa -d ipa
codesign -d --entitlements :- ipa/Payload/*.app
security cms -D -i ipa/Payload/*.app/embedded.mobileprovision | plutil -p - | grep -E "Name|aps-environment|get-task-allow"
Enter fullscreen mode Exit fullscreen mode

The two things that bounce most often: get-task-allow still true (a development profile slipped into the release build) and aps-environment set to development when push is enabled. Both look fine in app.json and in a config plugin's unit test, and both only show up in the signed bundle, same as your debug key.

Collapse
 
yujinumata profile image
Yuji Numata •

Thanks, this is useful. The kit is Android-only right now and I haven't built an .ipa from it yet, so I can't try these on a real bundle today. I've saved the commands for when I do.

The aps-environment one is a good catch. It would pass every config test I have, the same way the debug key did.

When get-task-allow is still true, does it fail at upload in App Store Connect, or later in review?

Collapse
 
hyunsoo_xenoci profile image
Hyunsoo Ju •

At upload, so you find out early rather than in review. App Store Connect validates the signature when the build is processed, and a binary with get-task-allow true means it was signed with a development profile. In my experience that fails during upload validation (the error mentions an invalid code signing entitlement), so it never reaches TestFlight, let alone review.

aps-environment is the sneakier one for exactly that reason: a development value can get through upload on some setups, and then push simply doesn't arrive in the production build. That's why I'd check the bundle instead of waiting for the store to complain.

Makes sense to keep them for when the kit gets an iOS target.

Thread Thread
 
yujinumata profile image
Yuji Numata •

So aps-environment is the worse one. Upload passes, nothing errors, and push just never shows up for real users. At least a debug-signed bundle gets refused at upload.

Thanks for explaining it. When I add the iOS target, these go in next to the keytool check.

Collapse
 
userxnom profile image
Abdullah Naseer •

This is the exact class of bug I find scariest — every test green, and the release still ships broken because the check looked at the template instead of the artifact. The keytool check for CN=Android Debug is such a cheap, decisive gate; I am adding a version of that to my own release flow. One thing I am curious about: does expo-play-check catch the AD_ID/BILLING manifest mismatch too, or is that still a manual step before you upload? And do you run it on every release branch in CI, or only when you prebuild?

Collapse
 
prikshit profile image
Prikshit •

Running keytool on the bundle is the check that actually proves the signing, since the plugin test only proved the regex matched an old template. A fixture copied from the current template on each React Native bump would catch the next syntax change before release. I'd also make the plugin fail loudly when the pattern matches nothing, instead of quietly returning the file unchanged.