From 08c16f8c1ae9fa9bc4d545b0c0c47152f5f1f3e9 Mon Sep 17 00:00:00 2001 From: Dotan Simha Date: Sun, 26 Oct 2025 17:00:54 +0200 Subject: [PATCH] fix(apollo-router-fork): use correct router version instead of commit env var --- .changeset/brown-ghosts-teach.md | 5 +++++ packages/libraries/router/src/agent.rs | 6 +++--- packages/libraries/router/src/consts.rs | 1 + packages/libraries/router/src/lib.rs | 1 + packages/libraries/router/src/main.rs | 1 + packages/libraries/router/src/registry.rs | 5 ++--- 6 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 .changeset/brown-ghosts-teach.md create mode 100644 packages/libraries/router/src/consts.rs diff --git a/.changeset/brown-ghosts-teach.md b/.changeset/brown-ghosts-teach.md new file mode 100644 index 00000000000..b67fff36a08 --- /dev/null +++ b/.changeset/brown-ghosts-teach.md @@ -0,0 +1,5 @@ +--- +'hive-apollo-router-plugin': patch +--- + +Use the correct plugin version in the User-Agent header used for Console requests diff --git a/packages/libraries/router/src/agent.rs b/packages/libraries/router/src/agent.rs index 477d245ce8e..e662ff941fb 100644 --- a/packages/libraries/router/src/agent.rs +++ b/packages/libraries/router/src/agent.rs @@ -1,3 +1,5 @@ +use crate::consts::PLUGIN_VERSION; + use super::graphql::OperationProcessor; use graphql_parser::schema::{parse_schema, Document}; use reqwest::Client; @@ -10,8 +12,6 @@ use std::{ use thiserror::Error; use tokio::sync::Mutex as AsyncMutex; -static COMMIT: Option<&'static str> = option_env!("GITHUB_SHA"); - #[derive(Serialize, Debug)] pub struct Report { size: usize, @@ -299,7 +299,7 @@ impl UsageAgent { ) .header( reqwest::header::USER_AGENT, - format!("hive-apollo-router/{}", COMMIT.unwrap_or("local")), + format!("hive-apollo-router/{}", PLUGIN_VERSION), ) .json(&report) .send() diff --git a/packages/libraries/router/src/consts.rs b/packages/libraries/router/src/consts.rs new file mode 100644 index 00000000000..9de035966be --- /dev/null +++ b/packages/libraries/router/src/consts.rs @@ -0,0 +1 @@ +pub const PLUGIN_VERSION: &str = env!("CARGO_PKG_VERSION"); diff --git a/packages/libraries/router/src/lib.rs b/packages/libraries/router/src/lib.rs index 89395180c93..c90d87cf65d 100644 --- a/packages/libraries/router/src/lib.rs +++ b/packages/libraries/router/src/lib.rs @@ -1,4 +1,5 @@ mod agent; +pub mod consts; mod graphql; pub mod persisted_documents; pub mod registry; diff --git a/packages/libraries/router/src/main.rs b/packages/libraries/router/src/main.rs index a0543cd19bb..c2f1f1ee70f 100644 --- a/packages/libraries/router/src/main.rs +++ b/packages/libraries/router/src/main.rs @@ -1,5 +1,6 @@ // Specify the modules our binary should include -- https://twitter.com/YassinEldeeb7/status/1468680104243077128 mod agent; +mod consts; mod graphql; mod persisted_documents; mod registry; diff --git a/packages/libraries/router/src/registry.rs b/packages/libraries/router/src/registry.rs index 195c43e3917..c0ab13b3001 100644 --- a/packages/libraries/router/src/registry.rs +++ b/packages/libraries/router/src/registry.rs @@ -1,3 +1,4 @@ +use crate::consts::PLUGIN_VERSION; use crate::registry_logger::Logger; use anyhow::{anyhow, Result}; use sha2::Digest; @@ -24,8 +25,6 @@ pub struct HiveRegistryConfig { schema_file_path: Option, } -static COMMIT: Option<&'static str> = option_env!("GITHUB_SHA"); - impl HiveRegistry { #[allow(clippy::new_ret_no_self)] pub fn new(user_config: Option) -> Result<()> { @@ -171,7 +170,7 @@ impl HiveRegistry { headers.insert( reqwest::header::USER_AGENT, reqwest::header::HeaderValue::from_str( - format!("hive-apollo-router/{}", COMMIT.unwrap_or("local")).as_str(), + format!("hive-apollo-router/{}", PLUGIN_VERSION).as_str(), ) .unwrap(), );