:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(cli): stop warning about expected sourcemap upload outcomes (#100707)
posthog[bot]b6486bfe18a1
diff --git a/cli/.sampo/changesets/sourcemap-upload-log-levels.md b/cli/.sampo/changesets/sourcemap-upload-log-levels.mdnew file mode 100644index 000000000000..2205c4e6bfb7--- /dev/null+++ b/cli/.sampo/changesets/sourcemap-upload-log-levels.md@@ -0,0 +1,5 @@+---+cargo/posthog-cli: patch+---++Stop reporting expected sourcemap upload outcomes as warnings. Missing releases and skipped empty sourcemaps now use lower log levels when uploads continue.diff --git a/cli/src/api/releases.rs b/cli/src/api/releases.rsindex 9320155365a7..2ee90be4fa07 100644--- a/cli/src/api/releases.rs+++ b/cli/src/api/releases.rs@@ -3,7 +3,7 @@ use std::collections::HashMap;use anyhow::{Context, Result};use serde::{Deserialize, Serialize};use serde_json::Value;-use tracing::{info, warn};+use tracing::{debug, info, warn};use uuid::Uuid;use crate::{@@ -50,7 +50,8 @@ impl Release {if let Err(err) = response {if let ClientError::ApiError(404, _, _) = err {- warn!("release {}@{} not found", name, version);+ // The caller creates the release after this, so a 404 is normal flow.+ debug!("release {}@{} not found", name, version);return Ok(None);}warn!("failed to get release from hash: {}", err);diff --git a/cli/src/sourcemaps/plain/upload.rs b/cli/src/sourcemaps/plain/upload.rsindex dfb20b162155..b0f75a15e19a 100644--- a/cli/src/sourcemaps/plain/upload.rs+++ b/cli/src/sourcemaps/plain/upload.rs@@ -18,6 +18,10 @@ use tracing::{debug, info, warn};/// extra glue (PostHog chunk-id IIFE, etc.) without misclassifying real code.const WRAPPER_JS_SIZE_THRESHOLD_BYTES: usize = 2048;+/// Cap on the suspect paths named in the summary line. They share one line, and an+/// oversized line kills the process on a non-blocking stderr pipe (see `FileSelectionArgs`).+const MAX_LISTED_SUSPECT_PATHS: usize = 3;+use crate::{api::{releases::Release,@@ -158,6 +162,7 @@ pub fn upload_pairs(.partition(|pair| pair.sourcemap.is_empty());let mut empty_skipped_wrapper = 0usize;let mut empty_skipped_suspect = 0usize;+ let mut suspect_paths: Vec<String> = Vec::new();for pair in &empty_pairs {let js_size = pair.source.inner.content.len();let map_path = pair.sourcemap.inner.path.display();@@ -169,12 +174,30 @@ pub fn upload_pairs();} else {empty_skipped_suspect += 1;- warn!(- "Skipping {}: sourcemap is empty but sibling JS is {} bytes — likely a bundler misconfiguration. Check your bundler's source-map setting (e.g. webpack `devtool`, Next.js `productionBrowserSourceMaps`, server compiler config).",+ if suspect_paths.len() < MAX_LISTED_SUSPECT_PATHS {+ suspect_paths.push(map_path.to_string());+ }+ debug!(+ "Skipping {}: sourcemap is empty but sibling JS is {} bytes — possible bundler misconfiguration",map_path, js_size);}}+ if empty_skipped_suspect > 0 {+ let unlisted = empty_skipped_suspect - suspect_paths.len();+ let rest = if unlisted > 0 {+ format!(" and {unlisted} more (set RUST_LOG=debug to list them all)")+ } else {+ String::new()+ };+ info!(+ "Skipped {} empty sourcemaps whose sibling JS file is at least {} bytes: {}{}. If those files must symbolicate, check your bundler's source-map setting (e.g. webpack `devtool`, Next.js `productionBrowserSourceMaps`, server compiler config).",+ empty_skipped_suspect,+ WRAPPER_JS_SIZE_THRESHOLD_BYTES,+ suspect_paths.join(", "),+ rest+ );+ }let empty_skipped = empty_pairs.len();let uploads = prepare_uploads(valid_pairs, args.release_mode)?;