Modern Apps git

← Modern-Apps.git

maps: manifest build ids parse as full u64 (#planet5)

Commit
d40c77c08815fc5ac1415b7d6d7713edc08596aa
Author
Vayun Mathur <[email protected]>
When
2026-11-14 23:47 UTC (21 days ago)
Parents
d332f63
MapOverlay.parseBuildId used toLongOrNull(16), which refuses any hex
value at or above 0x8000000000000000 and returned 0 for it. Build ids
are hashes, so half of all builds hit this, including both planet5
builds (0xcf5d201cf8720431 and now 0x8976ca07ca257b39). The client then
saw base build id 0 in the live manifest, which never equals the 64
bits it reads from the archive header, so a planet5 install could not
recognise its own base.

Found by MapOverlayLiveTest (MAMAPS_LIVE=1) against the newly published
~50 GB planet5 manifest: expected 0x8976ca07ca257b39, got 0.

Now parsed as ULong and carried as the same 64 bits in a Long, which
is how the header build id is read. Unit tests cover a top-bit-set id,
all-ones, and a 65-bit value (still 0).

Verified: :maps:testDevUnitTest --tests '*MapOverlay*' (26 pass,
including the live test against data.maproj.org) and :maps:lint.

Diff

maps/src/main/java/com/vayunmathur/maps/util/MapOverlay.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/util/MapOverlay.kt b/maps/src/main/java/com/vayunmathur/maps/util/MapOverlay.ktindex f6ab2a2d6a..5357e15a33 100644--- a/maps/src/main/java/com/vayunmathur/maps/util/MapOverlay.kt+++ b/maps/src/main/java/com/vayunmathur/maps/util/MapOverlay.kt@@ -144,9 +144,14 @@ object MapOverlay {     /**      * A `0x…` hex build id from the manifest, or 0 when it does not parse.      * Build ids are opaque equality tokens here (match the base or refuse).+     *+     * A build id is a full u64: parsed unsigned and carried as the same 64 bits in a Long.+     * `toLongOrNull(16)` refused anything at or above 0x8000000000000000 — half of all builds,+     * including both planet5 builds — and turned it into 0, so the manifest never matched the+     * header's build id.      */     fun parseBuildId(raw: String): Long =-        raw.removePrefix("0x").removePrefix("0X").toLongOrNull(BUILD_ID_RADIX) ?: 0L+        raw.removePrefix("0x").removePrefix("0X").toULongOrNull(BUILD_ID_RADIX)?.toLong() ?: 0L      /** Build ids are hex in the manifest and in logs. */     const val BUILD_ID_RADIX = 16
maps/src/test/java/com/vayunmathur/maps/util/MapOverlayTest.kt
diff --git a/maps/src/test/java/com/vayunmathur/maps/util/MapOverlayTest.kt b/maps/src/test/java/com/vayunmathur/maps/util/MapOverlayTest.ktindex 3e72d1da40..d763aac88e 100644--- a/maps/src/test/java/com/vayunmathur/maps/util/MapOverlayTest.kt+++ b/maps/src/test/java/com/vayunmathur/maps/util/MapOverlayTest.kt@@ -116,6 +116,10 @@ class MapOverlayTest {     fun build_ids_parse_hex_with_prefix() {         assertEquals(0x1234L, MapOverlay.parseBuildId("0x0000000000001234"))         assertEquals(0L, MapOverlay.parseBuildId("garbage"))+        // Top bit set (the published planet5 build): the same 64 bits as a signed Long.+        assertEquals(-0x768935f835da84c7L, MapOverlay.parseBuildId("0x8976ca07ca257b39"))+        assertEquals(-1L, MapOverlay.parseBuildId("0xffffffffffffffff"))+        assertEquals(0L, MapOverlay.parseBuildId("0x10000000000000000"))     }      @Test