Validate Android package names#581
Conversation
Greptile SummaryThis PR adds Android Application ID validation to the
Confidence Score: 4/5Safe to merge; the validation logic is correct and the tests cover the key rejection paths. The regex and guard function behave correctly for the documented Android Application ID rules. The only notable gap is that safeFileStem is still called on the already-validated package name, which is harmless but misleading — the two values will always be identical after validation passes. No files require special attention; both changed files are small and self-contained. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["build / ship called"] --> B["requirePackageName(config)"]
B --> C{"packageName.trim non-empty?"}
C -- No --> D["throw Error: invalid Android application ID"]
C -- Yes --> E{"ANDROID_PACKAGE_NAME_RE matches?"}
E -- No --> D
E -- Yes --> F["return trimmed packageName"]
F --> G["safeFileStem(packageName) - now redundant"]
G --> H["join outDir artifact path OR upload to Google Play"]
Reviews (1): Last reviewed commit: "Validate Android package names" | Re-trigger Greptile |
| ctx.log(`build Android AAB for ${packageName} v${ctx.version}`); | ||
| // TODO: run Gradle bundleRelease to produce signed .aab | ||
| return { artifact: join(ctx.outDir, `${safeFileStem(config.packageName)}-${safeFileStem(ctx.version)}.aab`) }; | ||
| return { artifact: join(ctx.outDir, `${safeFileStem(packageName)}-${safeFileStem(ctx.version)}.aab`) }; |
There was a problem hiding this comment.
After
requirePackageName validates successfully, packageName can only contain [a-zA-Z0-9_.] — exactly the characters that safeFileStem preserves unchanged. The replace/trim steps in safeFileStem become no-ops, so wrapping the already-safe string is dead weight. Using packageName directly is clearer and avoids the false impression that the stem might differ from the validated ID.
| return { artifact: join(ctx.outDir, `${safeFileStem(packageName)}-${safeFileStem(ctx.version)}.aab`) }; | |
| return { artifact: join(ctx.outDir, `${packageName}-${safeFileStem(ctx.version)}.aab`) }; |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Fixes #580.
Changes:
Validation: