fix(release): tolerate Forgejo null body/assets in release JSON

Gitea may emit null for empty release notes or assets; enable
Json.coerceInputValues and defaults so update checks do not fail
deserialization (unrelated to release-note workflow length).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
littlecodedragon 2026-05-11 07:04:04 +02:00
parent f91af6fc72
commit 6316b85a09
3 changed files with 13 additions and 7 deletions

View file

@ -128,6 +128,8 @@ class AppModule(val app: Application) : InjektModule {
Json {
ignoreUnknownKeys = true
explicitNulls = false
// Gitea/Forgejo often uses JSON null for empty release body or assets array.
coerceInputValues = true
}
}
addSingletonFactory {

View file

@ -5,17 +5,19 @@ import kotlinx.serialization.Serializable
/**
* Contains information about the latest release from GitHub.
* Forgejo/Gitea may send JSON `null` for empty [info] or [assets]; defaults + `Json.coerceInputValues`
* keep deserialization from failing.
*/
@Serializable
data class GithubRelease(
@SerialName("tag_name")
val version: String,
@SerialName("body")
val info: String,
val info: String = "",
@SerialName("html_url")
val releaseLink: String,
@SerialName("assets")
val assets: List<GitHubAsset>,
val assets: List<GitHubAsset> = emptyList(),
// KMK -->
@SerialName("prerelease")
val preRelease: Boolean = false,
@ -29,7 +31,7 @@ data class GithubRelease(
*/
@Serializable
data class GitHubAsset(
val name: String,
val name: String = "",
@SerialName("browser_download_url")
val downloadLink: String,
val downloadLink: String = "",
)

View file

@ -74,9 +74,11 @@ class ReleaseServiceImpl(
// KMK <--
private fun getDownloadLink(release: GithubRelease, isFoss: Boolean): String? {
val map = release.assets.associate { asset ->
BUILD_TYPES.find { "-$it" in asset.name } to asset.downloadLink
}
val map = release.assets
.filter { it.name.isNotBlank() && it.downloadLink.isNotBlank() }
.associate { asset ->
BUILD_TYPES.find { "-$it" in asset.name } to asset.downloadLink
}
return if (!isFoss) {
map[Build.SUPPORTED_ABIS[0]] ?: map[null]