From 79d4f7d33d75789a6aaef2f3b82d9a9a20659ed1 Mon Sep 17 00:00:00 2001 From: Finn Evers Date: Mon, 15 Dec 2025 12:01:15 +0100 Subject: [PATCH] extension_api: Add `digest` to `GithubReleaseAsset` (#44399) Release Notes: - N/A --- crates/extension_api/wit/since_v0.8.0/github.wit | 2 ++ crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs | 1 + crates/project/src/agent_server_store.rs | 6 +++--- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/extension_api/wit/since_v0.8.0/github.wit b/crates/extension_api/wit/since_v0.8.0/github.wit index 21cd5d48056af08441d3bb5aa8547edd97a874d7..6d7e5d952ae921925459f475bceb74d6c384d8be 100644 --- a/crates/extension_api/wit/since_v0.8.0/github.wit +++ b/crates/extension_api/wit/since_v0.8.0/github.wit @@ -13,6 +13,8 @@ interface github { name: string, /// The download URL for the asset. download-url: string, + /// The SHA-256 of the release asset if provided by the GitHub API. + digest: option, } /// The options used to filter down GitHub releases. diff --git a/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs b/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs index a2776f9f3b5b055d00787fb59c9bbca582352b1f..b32ab97983642d68aba041ee3afb902a0c5d2455 100644 --- a/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs +++ b/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs @@ -783,6 +783,7 @@ impl From<::http_client::github::GithubReleaseAsset> for github::GithubReleaseAs Self { name: value.name, download_url: value.browser_download_url, + digest: value.digest, } } } diff --git a/crates/project/src/agent_server_store.rs b/crates/project/src/agent_server_store.rs index a2cc57beae9702e4d5b495a135e7c357c638c17a..62937476b8eea4b30f02637b3501ea2b56db81a1 100644 --- a/crates/project/src/agent_server_store.rs +++ b/crates/project/src/agent_server_store.rs @@ -1495,7 +1495,7 @@ impl ExternalAgentServer for LocalCodex { let digest = asset .digest .as_deref() - .and_then(|d| d.strip_prefix("sha256:").or(Some(d))); + .map(|d| d.strip_prefix("sha256:").unwrap_or(d)); match ::http_client::github_download::download_server_binary( &*http, &asset.browser_download_url, @@ -1727,10 +1727,10 @@ impl ExternalAgentServer for LocalExtensionArchiveAgent { release.assets.iter().find(|a| a.name == filename) { // Strip "sha256:" prefix if present - asset.digest.as_ref().and_then(|d| { + asset.digest.as_ref().map(|d| { d.strip_prefix("sha256:") .map(|s| s.to_string()) - .or_else(|| Some(d.clone())) + .unwrap_or_else(|| d.clone()) }) } else { None