refactor(android): error messages come from the web's copy, one source for both apps (DRY B6)
release / web (push) Successful in 1m27s
release / go (push) Successful in 1m54s
release / govulncheck (push) Successful in 18s
release / android (push) Failing after 1m10s
release / integration (push) Successful in 4m9s
release / Build signed APK (push) Successful in 4m43s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Skipped
release / Verify release artifacts (tag releases only) (push) Skipped

Android's ErrorCopy was a hand-kept copy of web/src/lib/styles/
error-copy.json that had drifted: 14 of the web's codes were missing
(a server shutting down, a bad setting value, the backup and duplicates
codes), so those read "Something went wrong." on the phone, and only 2
of the web's 7 codes appended the server's specifics.

Now app/build.gradle.kts copies error-copy.json and a new
error-detail-codes.json (the list web/src/lib/api/errors.ts kept
inline) into the app's Java resources, and ErrorCopy reads them. The
three codes only Android had (auth_required, not_found,
cleartext_public) move into the shared file. PasswordRules' too-short
line is the shared password_too_short copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-27 14:11:34 -05:00
co-authored by Claude Opus 5.5
parent 25cee5ed69
commit 5d85739038
7 changed files with 100 additions and 69 deletions
+35
View File
@@ -100,6 +100,41 @@ android {
}
}
// The app's error messages are the web app's: web/src/lib/styles holds the
// copy for each server error code (error-copy.json) and the codes whose
// server message is appended (error-detail-codes.json). Both are copied in as
// Java resources, which ErrorCopy reads, so the two clients say the same thing
// and a new code is added once.
abstract class CopySharedCopyTask : DefaultTask() {
@get:InputFiles
@get:PathSensitive(PathSensitivity.NAME_ONLY)
abstract val sources: ConfigurableFileCollection
@get:OutputDirectory
abstract val outputDir: DirectoryProperty
@TaskAction
fun copy() {
val out = outputDir.get().asFile
out.deleteRecursively()
out.mkdirs()
sources.forEach { it.copyTo(File(out, it.name), overwrite = true) }
}
}
val copySharedCopy = tasks.register<CopySharedCopyTask>("copySharedCopy") {
sources.from(
rootProject.file("../web/src/lib/styles/error-copy.json"),
rootProject.file("../web/src/lib/styles/error-detail-codes.json"),
)
}
androidComponents {
onVariants { variant ->
variant.sources.resources?.addGeneratedSourceDirectory(copySharedCopy, CopySharedCopyTask::outputDir)
}
}
// Kotlin 2.x: `kotlinOptions { ... }` inside `android { }` is gone; the
// modern shape is the top-level `kotlin { compilerOptions { ... } }` block,
// which works whether Kotlin comes from AGP 9's built-in path or an