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:
parent
f91af6fc72
commit
6316b85a09
3 changed files with 13 additions and 7 deletions
|
|
@ -128,6 +128,8 @@ class AppModule(val app: Application) : InjektModule {
|
||||||
Json {
|
Json {
|
||||||
ignoreUnknownKeys = true
|
ignoreUnknownKeys = true
|
||||||
explicitNulls = false
|
explicitNulls = false
|
||||||
|
// Gitea/Forgejo often uses JSON null for empty release body or assets array.
|
||||||
|
coerceInputValues = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addSingletonFactory {
|
addSingletonFactory {
|
||||||
|
|
|
||||||
|
|
@ -5,17 +5,19 @@ import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains information about the latest release from GitHub.
|
* 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
|
@Serializable
|
||||||
data class GithubRelease(
|
data class GithubRelease(
|
||||||
@SerialName("tag_name")
|
@SerialName("tag_name")
|
||||||
val version: String,
|
val version: String,
|
||||||
@SerialName("body")
|
@SerialName("body")
|
||||||
val info: String,
|
val info: String = "",
|
||||||
@SerialName("html_url")
|
@SerialName("html_url")
|
||||||
val releaseLink: String,
|
val releaseLink: String,
|
||||||
@SerialName("assets")
|
@SerialName("assets")
|
||||||
val assets: List<GitHubAsset>,
|
val assets: List<GitHubAsset> = emptyList(),
|
||||||
// KMK -->
|
// KMK -->
|
||||||
@SerialName("prerelease")
|
@SerialName("prerelease")
|
||||||
val preRelease: Boolean = false,
|
val preRelease: Boolean = false,
|
||||||
|
|
@ -29,7 +31,7 @@ data class GithubRelease(
|
||||||
*/
|
*/
|
||||||
@Serializable
|
@Serializable
|
||||||
data class GitHubAsset(
|
data class GitHubAsset(
|
||||||
val name: String,
|
val name: String = "",
|
||||||
@SerialName("browser_download_url")
|
@SerialName("browser_download_url")
|
||||||
val downloadLink: String,
|
val downloadLink: String = "",
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -74,9 +74,11 @@ class ReleaseServiceImpl(
|
||||||
// KMK <--
|
// KMK <--
|
||||||
|
|
||||||
private fun getDownloadLink(release: GithubRelease, isFoss: Boolean): String? {
|
private fun getDownloadLink(release: GithubRelease, isFoss: Boolean): String? {
|
||||||
val map = release.assets.associate { asset ->
|
val map = release.assets
|
||||||
BUILD_TYPES.find { "-$it" in asset.name } to asset.downloadLink
|
.filter { it.name.isNotBlank() && it.downloadLink.isNotBlank() }
|
||||||
}
|
.associate { asset ->
|
||||||
|
BUILD_TYPES.find { "-$it" in asset.name } to asset.downloadLink
|
||||||
|
}
|
||||||
|
|
||||||
return if (!isFoss) {
|
return if (!isFoss) {
|
||||||
map[Build.SUPPORTED_ABIS[0]] ?: map[null]
|
map[Build.SUPPORTED_ABIS[0]] ?: map[null]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue