Skip to content

: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.

feat(error-tracking): fall back to the symbol set's release (#77554)

Aleksander Błaszkiewiczbcaa7e93c21e
diff --git a/proto/cymbal/resolution/v1/resolution.proto b/proto/cymbal/resolution/v1/resolution.proto
index 450e12c861a1..dfeb4962ac6c 100644
--- a/proto/cymbal/resolution/v1/resolution.proto
+++ b/proto/cymbal/resolution/v1/resolution.proto
@@ -60,6 +60,11 @@ message Done {
// remapping. It replaces only the submitted exception item, not the full
// event or exception list.
bytes resolved_exception_json = 1;
+ // UUID of the most recently created release bound to a symbol set this
+ // item's frames reference, as a hyphenated string. Empty when no referenced
+ // symbol set has a release, and on servers that predate this field, so
+ // callers must treat empty as "no release".
+ string release_id = 2;
}
// Error is a terminal item failure. The kind enum is the shared control-flow
diff --git a/rust/cymbal-proto/tests/contract.rs b/rust/cymbal-proto/tests/contract.rs
index 17aea85b8db3..28ba62113d43 100644
--- a/rust/cymbal-proto/tests/contract.rs
+++ b/rust/cymbal-proto/tests/contract.rs
@@ -30,6 +30,7 @@ fn resolve_outcome_echoes_id_and_carries_done_error_or_retry() {
id: 1,
result: Some(resolve_outcome::Result::Done(Done {
resolved_exception_json: br#"{"type":"ResolvedError"}"#.to_vec(),
+ release_id: "0198f0a4-0000-7000-8000-000000000001".to_string(),
})),
},
ResolveOutcome {
@@ -67,10 +68,11 @@ fn resolve_outcome_echoes_id_and_carries_done_error_or_retry() {
.map(|outcome| ResolveOutcome::decode(outcome.encode_to_vec().as_slice()).unwrap())
.collect();
- assert!(matches!(
- decoded[0].result,
- Some(resolve_outcome::Result::Done(_))
- ));
+ let Some(resolve_outcome::Result::Done(done)) = &decoded[0].result else {
+ panic!("expected a Done result, got {:?}", decoded[0].result);
+ };
+ assert_eq!(done.resolved_exception_json, br#"{"type":"ResolvedError"}"#);
+ assert_eq!(done.release_id, "0198f0a4-0000-7000-8000-000000000001");
assert!(matches!(
decoded[1].result,
Some(resolve_outcome::Result::Error(_))
diff --git a/rust/cymbal/.sqlx/query-ad91c3bfdfee6139bb04dea5773481fe9f2f6857e394b51b88c7977fa6287b75.json b/rust/cymbal/.sqlx/query-ad91c3bfdfee6139bb04dea5773481fe9f2f6857e394b51b88c7977fa6287b75.json
new file mode 100644
index 000000000000..b4186d2727e3
--- /dev/null
+++ b/rust/cymbal/.sqlx/query-ad91c3bfdfee6139bb04dea5773481fe9f2f6857e394b51b88c7977fa6287b75.json
@@ -0,0 +1,23 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT r.id\n FROM posthog_errortrackingsymbolset ss\n INNER JOIN posthog_errortrackingrelease r ON ss.release_id = r.id\n WHERE ss.ref = ANY($1) AND ss.team_id = $2\n ORDER BY r.created_at DESC, r.id DESC\n LIMIT 1\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "id",
+ "type_info": "Uuid"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "TextArray",
+ "Int4"
+ ]
+ },
+ "nullable": [
+ false
+ ]
+ },
+ "hash": "ad91c3bfdfee6139bb04dea5773481fe9f2f6857e394b51b88c7977fa6287b75"
+}
diff --git a/rust/cymbal/docs/compatibility.md b/rust/cymbal/docs/compatibility.md
index b735e6ec8b48..add4b064f27e 100644
--- a/rust/cymbal/docs/compatibility.md
+++ b/rust/cymbal/docs/compatibility.md
@@ -27,6 +27,7 @@ No generated type changes are needed:
- Events use the remote pool and do not silently fall back to inline resolution on failures.
- Events are flattened into exception-level `ResolveItem`s. Items are grouped by their first symbol-set reference when available, with a per-team fallback, then submitted over per-endpoint bidirectional `Resolve` streams.
- Resolver-specific context is carried in `ResolveItem.metadata` as JSON bytes. The native symbolication convention uses a `debug_images_json` key.
+- `Done.release_id` carries the newest release bound to a symbol set the item's frames reference. It is empty when none of them has a release, and on servers that predate the field, so callers treat empty as "no release". The processing side uses it only as the fallback source for `$exception_release`, behind the event's own `$release_id` and mobile app metadata.
- Per-item `ResolveOutcome.Error.kind` is the control-flow surface. `ERROR_KIND_OVERLOADED` is result-only backpressure and triggers item reroute. Accepted items emit `ResolveOutcome.Accepted` before their terminal outcome; cymbal releases its routing permit on that acceptance signal. If `CYMBAL_REMOTE_RESOLUTION_OVERLOAD_EJECTION_MS` is non-zero, the overloaded endpoint is also temporarily excluded from new routing in that cymbal process. Repeated overloads double that cooldown up to `CYMBAL_REMOTE_RESOLUTION_OVERLOAD_EJECTION_MAX_MS`, and a quiet `CYMBAL_REMOTE_RESOLUTION_OVERLOAD_EJECTION_DECAY_MS` window resets it. `CYMBAL_REMOTE_RESOLUTION_ROUTING_JITTER` controls how much routing flattens across the load-adjusted rendezvous-ranked candidate list (`0.0` strict top load-adjusted candidate, `1.0` load-weighted across candidates). `LoadEvent` carries endpoint freshness/draining state plus `in_flight` / `max_in_flight` as a soft routing load signal.
This means Node request chunking limits protect cymbal's public HTTP body size, while cymbal's private gRPC path owns exception-level routing, reroute depth, and overload handling.
diff --git a/rust/cymbal/src/core/config.rs b/rust/cymbal/src/core/config.rs
index 00922cbb7d0c..075454e8018b 100644
--- a/rust/cymbal/src/core/config.rs
+++ b/rust/cymbal/src/core/config.rs
@@ -74,6 +74,19 @@ pub struct ResolverConfig {
#[envconfig(default = "300")]
pub symbol_set_negative_cache_ttl_seconds: u64,
+ // TTL for the (team, symbol-set refs) -> latest-release-id cache in the resolution
+ // service. Kept short because a release (re)bound to already-cached refs only becomes
+ // visible after expiry; new releases usually ship new refs, which miss naturally.
+ #[envconfig(default = "60")]
+ pub release_id_cache_ttl_seconds: u64,
+
+ // Byte budget for that cache, weighed by the ref bytes each entry holds. Refs are
+ // event-controlled (frame source URLs, chunk ids), so an entry-count bound would let a
+ // flood of unique long refs grow the cache without limit. 32 MiB comfortably holds the
+ // working set of a 60s TTL at typical ref-set sizes.
+ #[envconfig(default = "33554432")]
+ pub release_id_cache_max_bytes: u64,
+
// Maximum number of lines of pre and post context to get per frame
#[envconfig(default = "15")]
pub context_line_count: usize,
diff --git a/rust/cymbal/src/core/metric_consts.rs b/rust/cymbal/src/core/metric_consts.rs
index 5a2e0f45d462..609f5e9878a9 100644
--- a/rust/cymbal/src/core/metric_consts.rs
+++ b/rust/cymbal/src/core/metric_consts.rs
@@ -23,6 +23,8 @@ pub const FRAME_CACHE_MISSES: &str = "cymbal_frame_cache_misses";
pub const FRAME_DB_HITS: &str = "cymbal_frame_db_hits";
pub const FRAME_DB_MISSES: &str = "cymbal_frame_db_misses";
pub const FRAME_NOT_RESOLVED: &str = "cymbal_frame_not_resolved";
+pub const RELEASE_ID_CACHE_HITS: &str = "cymbal_release_id_cache_hits";
+pub const RELEASE_ID_CACHE_MISSES: &str = "cymbal_release_id_cache_misses";
// Client-expanded native inline groups, labeled by outcome: "replaced" when the
// server expansion of the group's address superseded the client frames, "kept"
// when resolution failed and the client expansion passed through.
diff --git a/rust/cymbal/src/core/symbolication/symbol/local.rs b/rust/cymbal/src/core/symbolication/symbol/local.rs
index 29a35487ae3c..225eb507e52a 100644
--- a/rust/cymbal/src/core/symbolication/symbol/local.rs
+++ b/rust/cymbal/src/core/symbolication/symbol/local.rs
@@ -16,11 +16,11 @@ use sqlx::PgPool;
use crate::{
core::config::ResolverConfig,
error::{JsResolveErr, ProguardError, ResolveError, UnhandledError},
- frames::{Frame, RawFrame},
+ frames::{releases::ReleaseRecord, Frame, RawFrame},
langs::native::DebugImage,
metric_consts::{
FRAME_CACHE_HITS, FRAME_CACHE_MISSES, FRAME_DB_HITS, FRAME_DB_MISSES,
- SUSPICIOUS_FRAMES_DETECTED,
+ RELEASE_ID_CACHE_HITS, RELEASE_ID_CACHE_MISSES, SUSPICIOUS_FRAMES_DETECTED,
},
symbolication::resolve::Resolve,
symbolication::symbol::records::{ErrorTrackingStackFrame, FrameResultTtlPolicy},
@@ -29,11 +29,12 @@ use crate::{
chunk_id::OrChunkId,
dart_minified_names::lookup_minified_type,
proguard::{FetchedMapping, ProguardRef},
- saving::SymbolSetRecord,
+ saving::{truncate_ref, SymbolSetRecord},
Catalog,
},
types::operator::TeamId,
};
+use uuid::Uuid;
const FRAME_EXPIRY_FALLBACK_SECONDS: u64 = 300;
@@ -41,6 +42,12 @@ const FRAME_EXPIRY_FALLBACK_SECONDS: u64 = 300;
pub struct LocalSymbolResolver {
catalog: Arc<Catalog>,
cache: Cache<RawFrameId, Vec<ErrorTrackingStackFrame>>,
+ // (team_id, sorted truncated refs) -> latest release id, including None results. Without
+ // this, every exception with symbol-set refs costs one Postgres query per resolve, even
+ // when frame resolution itself is fully served from the frame cache above. Refs are
+ // event-controlled, so the cache is byte-weighted rather than entry-counted, like the
+ // negative cache in the Saving layer.
+ release_id_cache: Cache<(TeamId, Vec<String>), Option<Uuid>>,
pool: PgPool,
ttl_policy: FrameResultTtlPolicy,
// Lines of pre/post source context to attach per resolved frame.
@@ -92,10 +99,23 @@ impl LocalSymbolResolver {
.expire_after(ttl_policy)
.build();
+ let release_id_cache = CacheBuilder::new(config.release_id_cache_max_bytes)
+ .weigher(|(_, refs): &(TeamId, Vec<String>), _: &Option<Uuid>| {
+ // Bound by the bytes actually held; saturate rather than wrap for huge keys.
+ refs.iter()
+ .map(String::len)
+ .sum::<usize>()
+ .try_into()
+ .unwrap_or(u32::MAX)
+ })
+ .time_to_live(Duration::from_secs(config.release_id_cache_ttl_seconds))
+ .build();
+
Self {
catalog,
pool,
cache,
+ release_id_cache,
ttl_policy,
context_lines: config.context_line_count,
}
@@ -233,6 +253,44 @@ impl SymbolResolver for LocalSymbolResolver {
lookup_minified_type(minified_names, minified_name)
.ok_or(ResolveError::from(JsResolveErr::InvalidSourceAndMap))
}
+
+ async fn latest_release_id(
+ &self,
+ team_id: TeamId,
+ symbol_set_refs: &[String],
+ ) -> Result<Option<Uuid>, UnhandledError> {
+ if symbol_set_refs.is_empty() {
+ return Ok(None);
+ }
+
+ // Truncated to the ref size the DB matches on, which caps what an event-controlled
+ // ref can pin in the cache key. Sorted so frame-order variations of the same stack
+ // share a cache entry, and deduped because truncation can collapse distinct refs.
+ let mut refs: Vec<String> = symbol_set_refs
+ .iter()
+ .map(|r| truncate_ref(r).to_string())
+ .collect();
+ refs.sort_unstable();
+ refs.dedup();
+
+ let mut cache_miss = false;
+ let release_id = self
+ .release_id_cache
+ .try_get_with((team_id, refs.clone()), async {
+ cache_miss = true;
+ ReleaseRecord::latest_id_for_symbol_set_refs(&self.pool, &refs, team_id).await
+ })
+ .await
+ .map_err(|e| UnhandledError::Other(e.to_string()))?;
+
+ if cache_miss {
+ metrics::counter!(RELEASE_ID_CACHE_MISSES).increment(1);
+ } else {
+ metrics::counter!(RELEASE_ID_CACHE_HITS).increment(1);
+ }
+
+ Ok(release_id)
+ }
}
#[cfg(test)]
@@ -246,6 +304,7 @@ mod test {
use mockall::predicate;
use sqlx::PgPool;
use symbolic::sourcemapcache::SourceMapCacheWriter;
+ use uuid::Uuid;
use crate::{
core::config::ResolverConfig,
@@ -259,7 +318,7 @@ mod test {
hermesmap::HermesMapProvider,
native::NativeProvider,
proguard::ProguardProvider,
- saving::{Saving, SymbolSetRecord},
+ saving::{truncate_ref, Saving, SymbolSetRecord, MAX_REF_BYTES},
sourcemap::SourcemapProvider,
Catalog, MockS3Client,
},
@@ -481,4 +540,100 @@ mod test {
assert_eq!(resolved_1, resolved_2);
assert_eq!(resolved_2, resolved_3);
}
+
+ async fn insert_release(pool: &PgPool, team_id: i32, days_ago: i32) -> Uuid {
+ let id = Uuid::new_v4();
+ sqlx::query(
+ "INSERT INTO posthog_errortrackingrelease (id, team_id, hash_id, created_at, version, project)
+ VALUES ($1, $2, $3, NOW() - make_interval(days => $4), '1.0', 'test-project')",
+ )
+ .bind(id)
+ .bind(team_id)
+ .bind(id.to_string())
+ .bind(days_ago)
+ .execute(pool)
+ .await
+ .unwrap();
+ id
+ }
+
+ async fn bind_symbol_set(pool: &PgPool, team_id: i32, set_ref: &str, release_id: Uuid) {
+ sqlx::query(
+ "INSERT INTO posthog_errortrackingsymbolset (id, ref, team_id, release_id)
+ VALUES ($1, $2, $3, $4)",
+ )
+ .bind(Uuid::new_v4())
+ .bind(set_ref)
+ .bind(team_id)
+ .bind(release_id)
+ .execute(pool)
+ .await
+ .unwrap();
+ }
+
+ #[sqlx::test(migrations = "./tests/test_migrations")]
+ pub async fn latest_release_id_is_cached_and_ref_order_insensitive(pool: PgPool) {
+ let (config, catalog, _server) = setup_test_context(pool.clone(), |_, client| client).await;
+ let resolver = LocalSymbolResolver::new(&config, Arc::new(catalog), pool.clone());
+
+ let team_id = 0;
+ let old_release = insert_release(&pool, team_id, 1).await;
+ bind_symbol_set(&pool, team_id, "ref_a", old_release).await;
+
+ let first = resolver
+ .latest_release_id(team_id, &["ref_b".to_string(), "ref_a".to_string()])
+ .await
+ .unwrap();
+ assert_eq!(first, Some(old_release));
+
+ // A fresh query would now return the newer release, so getting the old id back for the
+ // reordered refs proves the lookup was served from the cache under a normalized key.
+ let new_release = insert_release(&pool, team_id, 0).await;
+ bind_symbol_set(&pool, team_id, "ref_b", new_release).await;
+
+ let second = resolver
+ .latest_release_id(team_id, &["ref_a".to_string(), "ref_b".to_string()])
+ .await
+ .unwrap();
+ assert_eq!(second, Some(old_release));
+ }
+
+ #[sqlx::test(migrations = "./tests/test_migrations")]
+ pub async fn latest_release_id_cache_key_uses_truncated_refs(pool: PgPool) {
+ let (config, catalog, _server) = setup_test_context(pool.clone(), |_, client| client).await;
+ let resolver = LocalSymbolResolver::new(&config, Arc::new(catalog), pool.clone());
+
+ let team_id = 0;
+ // Two refs the DB treats as the same symbol set: identical up to the stored ref
+ // size, differing only past it.
+ let prefix = "a".repeat(MAX_REF_BYTES);
+ let ref_one = format!("{prefix}_tail_one");
+ let ref_two = format!("{prefix}_tail_two");
+
+ let old_release = insert_release(&pool, team_id, 1).await;
+ bind_symbol_set(&pool, team_id, truncate_ref(&ref_one), old_release).await;
+
+ let first = resolver
+ .latest_release_id(team_id, &[ref_one])
+ .await
+ .unwrap();
+ assert_eq!(first, Some(old_release));
+
+ // Rebind the set so a fresh query would return the newer release; getting the old id
+ // back for a ref with a different over-length tail proves both refs normalize to the
+ // same truncated cache key.
+ let new_release = insert_release(&pool, team_id, 0).await;
+ sqlx::query("UPDATE posthog_errortrackingsymbolset SET release_id = $1 WHERE team_id = $2")
+ .bind(new_release)
+ .bind(team_id)
+ .execute(&pool)
+ .await
+ .unwrap();
+
+ let second = resolver
+ .latest_release_id(team_id, &[ref_two])
+ .await
+ .unwrap();
+ assert_eq!(second, Some(old_release));
+ }
}
diff --git a/rust/cymbal/src/core/symbolication/symbol/mod.rs b/rust/cymbal/src/core/symbolication/symbol/mod.rs
index e0d192534b5b..5283f014542f 100644
--- a/rust/cymbal/src/core/symbolication/symbol/mod.rs
+++ b/rust/cymbal/src/core/symbolication/symbol/mod.rs
@@ -10,6 +10,7 @@ use crate::{
symbolication::symbol_store::{chunk_id::OrChunkId, proguard::ProguardRef},
};
use tracing::debug;
+use uuid::Uuid;
pub mod local;
pub mod records;
@@ -36,6 +37,17 @@ pub trait SymbolResolver: Send + Sync + 'static {
minified_name: &str,
) -> Result<String, ResolveError>;
+ /// The newest release bound to any of `symbol_set_refs`. Lives here because only a resolver
+ /// backed by the symbol-set store can answer it; resolvers without one (test fakes) inherit
+ /// the "no release" default.
+ async fn latest_release_id(
+ &self,
+ _team_id: TeamId,
+ _symbol_set_refs: &[String],
+ ) -> Result<Option<Uuid>, UnhandledError> {
+ Ok(None)
+ }
+
async fn resolve_java_exception(
&self,
team_id: TeamId,
diff --git a/rust/cymbal/src/core/symbolication/symbol/records.rs b/rust/cymbal/src/core/symbolication/symbol/records.rs
index e53608af9dc9..815fb0f9b2f9 100644
--- a/rust/cymbal/src/core/symbolication/symbol/records.rs
+++ b/rust/cymbal/src/core/symbolication/symbol/records.rs
@@ -138,7 +138,7 @@ impl ErrorTrackingStackFrame {
ttl_policy: FrameResultTtlPolicy,
) -> Result<Vec<Self>, UnhandledError>
where
- E: Executor<'c, Database = sqlx::Postgres> + Clone,
+ E: Executor<'c, Database = sqlx::Postgres>,
{
struct Returned {
raw_id: String,
@@ -161,7 +161,7 @@ impl ErrorTrackingStackFrame {
id.hash_id,
id.team_id
)
- .fetch_all(e.clone())
+ .fetch_all(e)
.await?;
if res.is_empty() {
diff --git a/rust/cymbal/src/core/symbolication/symbol_store/saving.rs b/rust/cymbal/src/core/symbolication/symbol_store/saving.rs
index 32ee989b62cb..0a58c31f6596 100644
--- a/rust/cymbal/src/core/symbolication/symbol_store/saving.rs
+++ b/rust/cymbal/src/core/symbolication/symbol_store/saving.rs
@@ -23,7 +23,7 @@ use crate::{
use super::{Fetcher, Parser};
-const MAX_REF_BYTES: usize = 2048;
+pub(crate) const MAX_REF_BYTES: usize = 2048;
// Total byte budget for the in-memory negative cache. Refs and failure reasons are
// event-controlled (a JS frame's ref is its source URL, and a `NoSourcemap` failure embeds that
@@ -34,7 +34,7 @@ const NEGATIVE_CACHE_MAX_WEIGHT: u64 = 64 * 1024 * 1024;
// We truncate the reference to resolve an issue with the maximum size in a BTRee index on Postgres
// TODO: update model to use a hash of the reference instead
-fn truncate_ref(s: &str) -> &str {
+pub(crate) fn truncate_ref(s: &str) -> &str {
if s.len() <= MAX_REF_BYTES {
return s;
}
diff --git a/rust/cymbal/src/core/types/frames/releases.rs b/rust/cymbal/src/core/types/frames/releases.rs
index ae99af412d0e..327cd1d7675d 100644
--- a/rust/cymbal/src/core/types/frames/releases.rs
+++ b/rust/cymbal/src/core/types/frames/releases.rs
@@ -5,6 +5,8 @@ use sha2::{Digest, Sha512};
use sqlx::Executor;
use uuid::Uuid;
+use crate::symbolication::symbol_store::saving::truncate_ref;
+
/// The release API does not bound what a row can hold (`version`/`project`/`metadata` are
/// unbounded TextField/JSONField columns), but every one of these fields is embedded into every
/// matching exception event, so a single oversized row would be amplified across the whole event
@@ -84,6 +86,43 @@ impl ReleaseRecord {
Ok(row.map(Self::clamped))
}
+ /// The newest release bound to any of `symbol_set_refs`, as an id. One query per exception
+ /// replaces the per-frame join the resolver used to run, and the id is all the caller needs:
+ /// it re-reads the row through its own release cache.
+ ///
+ /// Ties break on id so a stack spanning two releases created in the same instant still picks
+ /// deterministically.
+ pub async fn latest_id_for_symbol_set_refs<'c, E>(
+ e: E,
+ symbol_set_refs: &[String],
+ team_id: i32,
+ ) -> Result<Option<Uuid>, sqlx::Error>
+ where
+ E: Executor<'c, Database = sqlx::Postgres>,
+ {
+ // Stored refs are truncated to MAX_REF_BYTES by SymbolSetRecord::load/save; match on the
+ // same truncated value or long refs (e.g. >2KB JS source URLs) never join.
+ let refs: Vec<String> = symbol_set_refs
+ .iter()
+ .map(|r| truncate_ref(r).to_string())
+ .collect();
+
+ sqlx::query_scalar!(
+ r#"
+ SELECT r.id
+ FROM posthog_errortrackingsymbolset ss
+ INNER JOIN posthog_errortrackingrelease r ON ss.release_id = r.id
+ WHERE ss.ref = ANY($1) AND ss.team_id = $2
+ ORDER BY r.created_at DESC, r.id DESC
+ LIMIT 1
+ "#,
+ &refs,
+ team_id
+ )
+ .fetch_optional(e)
+ .await
+ }
+
pub fn to_info(&self) -> ReleaseInfo {
ReleaseInfo {
id: self.id,
@@ -94,9 +133,17 @@ impl ReleaseRecord {
}
}
- /// Bounds every field this record can carry into an event: `metadata` over the cap the API
- /// enforces on new writes is dropped, `version`/`project` are truncated. The `id` survives,
- /// so consumers can still fetch the full release.
+ /// The most recently created release, with ties broken by id so the pick is deterministic
+ /// regardless of input order.
+ pub fn latest(releases: impl IntoIterator<Item = Self>) -> Option<Self> {
+ releases
+ .into_iter()
+ .max_by_key(|release| (release.created_at, release.id))
+ }
+
+ /// Bounds every field this record can carry into an event: `metadata` over the cap is
+ /// dropped, `version`/`project` are truncated. The `id` survives, so consumers can still
+ /// fetch the full release.
fn clamped(mut self) -> Self {
let oversized = self.metadata.as_ref().is_some_and(|metadata| {
serde_json::to_string(metadata).map_or(true, |s| s.len() > MAX_RELEASE_METADATA_BYTES)
diff --git a/rust/cymbal/src/modes/processing/stages/resolution/event_release.rs b/rust/cymbal/src/modes/processing/stages/resolution/event_release.rs
index 6a43756a7eb2..4497c25eb22c 100644
--- a/rust/cymbal/src/modes/processing/stages/resolution/event_release.rs
+++ b/rust/cymbal/src/modes/processing/stages/resolution/event_release.rs
@@ -2,7 +2,7 @@ use std::{collections::HashMap, sync::Arc, time::Duration};
use moka::future::{Cache, CacheBuilder};
use serde_json::Value;
-use sqlx::{Executor, Postgres};
+use sqlx::{Executor, PgPool, Postgres};
use uuid::Uuid;
use crate::{
@@ -99,20 +99,20 @@ fn record_cache_outcome(cache_type: &'static str, cache_miss: bool) {
metrics::counter!(ANCILLARY_CACHE, "type" => cache_type, "outcome" => outcome).increment(1);
}
-/// Resolves the event-level release without going through the per-frame symbol-set join, so the
-/// release is independent of which chunks resolved the stack. Runs inside `ResolutionStage` after
-/// `resolve_batch`, so a future fallback for legacy events (which carry neither `$release_id` nor
-/// app metadata) can read the resolved frames' symbol sets.
+/// Resolves the single release an event reports as `$exception_release`. Runs inside
+/// `ResolutionStage` after `resolve_batch`, because its last source is what resolution found.
///
-/// Two sources, in order of preference:
+/// Three sources, in order of preference:
/// 1. `$release_id` — web builds inject the release row's id, which the SDK emits verbatim. Direct
/// foreign-key lookup.
/// 2. app metadata — mobile SDKs inject nothing, but every event already carries `$app_namespace`,
/// `$app_version`, and `$app_build`, which the CLI hashed into the release when it uploaded the
/// dSYMs. We reconstruct that hash and look the release up by it.
+/// 3. the releases bound to the symbol sets resolution used, which covers events that carry
+/// neither. One id per exception comes back on the wire; the newest wins, so an event whose
+/// stack mixes symbol sets from several releases reports the latest.
///
-/// When neither resolves, the event release stays unset and `$exception_release` is omitted;
-/// there is no per-frame fallback yet.
+/// When none resolve, the event release stays unset and `$exception_release` is omitted.
#[derive(Clone, Default)]
pub struct EventReleaseResolver;
@@ -131,30 +131,54 @@ impl ValueOperator for EventReleaseResolver {
mut evt: ExceptionEvent<Parsed>,
ctx: ResolutionStage,
) -> OperatorResult<Self> {
- let release_id = evt
- .properties()
- .get("$release_id")
- .and_then(Value::as_str)
- .and_then(|id| Uuid::parse_str(id).ok());
-
- if let Some(release_id) = release_id {
- let record = ctx
- .release_cache
- .for_id(&ctx.posthog_pool, release_id, evt.team_id())
- .await?;
- evt.set_event_release(record);
- } else if let Some(hash_id) = mobile_release_hash_from_props(evt.properties()) {
- let record = ctx
- .release_cache
- .for_hash(&ctx.posthog_pool, &hash_id, evt.team_id())
- .await?;
- evt.set_event_release(record);
- }
+ let record = select_release(
+ &ctx.posthog_pool,
+ &ctx.release_cache,
+ evt.team_id(),
+ evt.properties(),
+ evt.symbol_set_release_ids(),
+ )
+ .await?;
+
+ evt.set_event_release(record);
Ok(Ok(evt))
}
}
+async fn select_release(
+ pool: &PgPool,
+ cache: &ReleaseCache,
+ team_id: TeamId,
+ props: &HashMap<String, Value>,
+ symbol_set_release_ids: &[Uuid],
+) -> Result<Option<ReleaseRecord>, UnhandledError> {
+ let release_id = props
+ .get("$release_id")
+ .and_then(Value::as_str)
+ .and_then(|id| Uuid::parse_str(id).ok());
+
+ let record = if let Some(release_id) = release_id {
+ cache.for_id(pool, release_id, team_id).await?
+ } else if let Some(hash_id) = mobile_release_hash_from_props(props) {
+ cache.for_hash(pool, &hash_id, team_id).await?
+ } else {
+ None
+ };
+
+ if let Some(record) = record {
+ return Ok(Some(record));
+ }
+
+ // Reached when the event carries no release identifier, and also when the one it carries
+ // points at a release that no longer exists.
+ let mut candidates = Vec::new();
+ for id in symbol_set_release_ids {
+ candidates.extend(cache.for_id(pool, *id, team_id).await?);
+ }
+ Ok(ReleaseRecord::latest(candidates))
+}
+
/// Rebuild the release `hash_id` from a mobile event's app metadata. Returns `None` for events that
/// aren't from a mobile SDK (no `$app_namespace`) or lack any version info to key on.
///
@@ -211,4 +235,83 @@ mod tests {
None
);
}
+
+ const TEAM_ID: TeamId = 1;
+
+ async fn insert_release(pool: &PgPool, hash_id: &str, created_secs: i64) -> Uuid {
+ let id = Uuid::now_v7();
+ sqlx::query(
+ r#"
+ INSERT INTO posthog_errortrackingrelease (id, team_id, hash_id, created_at, version, project)
+ VALUES ($1, $2, $3, $4, $5, $6)
+ "#,
+ )
+ .bind(id)
+ .bind(TEAM_ID)
+ .bind(hash_id)
+ .bind(chrono::DateTime::from_timestamp(created_secs, 0).unwrap())
+ .bind(format!("1.0.{created_secs}"))
+ .bind("my-app")
+ .execute(pool)
+ .await
+ .unwrap();
+ id
+ }
+
+ async fn select(
+ pool: &PgPool,
+ properties: Value,
+ symbol_set_release_ids: &[Uuid],
+ ) -> Option<ReleaseRecord> {
+ // A fresh cache per call: these cases assert selection, not cache behavior.
+ let cache = ReleaseCache::new(64, Duration::from_secs(60));
+ select_release(
+ pool,
+ &cache,
+ TEAM_ID,
+ &props(properties),
+ symbol_set_release_ids,
+ )
+ .await
+ .unwrap()
+ }
+
+ #[sqlx::test(migrations = "./tests/test_migrations")]
+ async fn symbol_set_releases_only_fill_the_gap_left_by_the_event_level_sources(pool: PgPool) {
+ let event_release = insert_release(&pool, "event-hash", 100).await;
+ let older = insert_release(&pool, "older-hash", 200).await;
+ let newer = insert_release(&pool, "newer-hash", 5_000).await;
+ let symbol_set_ids = [newer, older];
+
+ let selected = select(
+ &pool,
+ json!({ "$release_id": event_release.to_string() }),
+ &symbol_set_ids,
+ )
+ .await;
+ assert_eq!(
+ selected.map(|r| r.id),
+ Some(event_release),
+ "the event's own release outranks the symbol sets', even when theirs is newer"
+ );
+
+ let selected = select(&pool, json!({}), &symbol_set_ids).await;
+ assert_eq!(
+ selected.map(|r| r.id),
+ Some(newer),
+ "with no event-level release, the newest symbol-set release wins regardless of order"
+ );
+
+ // A `$release_id` for a release that has since been deleted resolves to nothing, so the
+ // fallback still applies.
+ let selected = select(
+ &pool,
+ json!({ "$release_id": Uuid::now_v7().to_string() }),
+ &[older],
+ )
+ .await;
+ assert_eq!(selected.map(|r| r.id), Some(older));
+
+ assert!(select(&pool, json!({}), &[]).await.is_none());
+ }
}
diff --git a/rust/cymbal/src/modes/processing/stages/resolution/remote/mux.rs b/rust/cymbal/src/modes/processing/stages/resolution/remote/mux.rs
index ff9ac7c89ed2..50a25c24e5da 100644
--- a/rust/cymbal/src/modes/processing/stages/resolution/remote/mux.rs
+++ b/rust/cymbal/src/modes/processing/stages/resolution/remote/mux.rs
@@ -427,6 +427,7 @@ mod tests {
id: item.id,
result: Some(resolve_outcome::Result::Done(Done {
resolved_exception_json: item.exception_json,
+ release_id: String::new(),
})),
};
tx.send(Ok(outcome)).await.expect("test receiver is alive");
diff --git a/rust/cymbal/src/modes/processing/stages/resolution/remote/resolver.rs b/rust/cymbal/src/modes/processing/stages/resolution/remote/resolver.rs
index 62aba2a4003a..f0cd0b05587c 100644
--- a/rust/cymbal/src/modes/processing/stages/resolution/remote/resolver.rs
+++ b/rust/cymbal/src/modes/processing/stages/resolution/remote/resolver.rs
@@ -5,6 +5,7 @@ use std::time::{Duration, Instant};
use cymbal_proto::cymbal::resolution::v1::ResolveItem;
use futures::future::join_all;
use tokio::sync::Semaphore;
+use uuid::Uuid;
use crate::{
error::UnhandledError,
@@ -134,6 +135,9 @@ struct RemoteEventSlot {
evt: ExceptionEvent<Parsed>,
resolved: Vec<Option<Exception>>,
legacy_resolved: Option<Vec<Option<Exception>>>,
+ /// Releases the resolver bound to this event's exceptions, one per canonical item that had
+ /// one. The legacy-order snapshot resolves the same frames, so its ids are redundant.
+ release_ids: Vec<Uuid>,
}
#[derive(Clone, Copy)]
@@ -167,6 +171,7 @@ struct ResolvedRemoteItem {
exception_slot: usize,
target: ResolutionTarget,
exception: Exception,
+ release_id: Option<Uuid>,
}
// ─────────────────────────────────────────────────────────────────────────────
@@ -201,6 +206,11 @@ async fn resolve_remote_events(
item.event_slot
)));
};
+ if let (ResolutionTarget::Canonical, Some(release_id)) = (item.target, item.release_id) {
+ if !event_slot.release_ids.contains(&release_id) {
+ event_slot.release_ids.push(release_id);
+ }
+ }
let slots = match item.target {
ResolutionTarget::Canonical => &mut event_slot.resolved,
ResolutionTarget::Legacy => event_slot.legacy_resolved.as_mut().ok_or_else(|| {
@@ -243,6 +253,7 @@ async fn resolve_remote_events(
event
.evt
.replace_exception_list(ExceptionList::from(exceptions));
+ event.evt.set_symbol_set_release_ids(event.release_ids);
if let Some(legacy) = event.legacy_resolved {
let legacy = legacy
.into_iter()
@@ -341,6 +352,7 @@ fn build_work_items(
event_slots.push(RemoteEventSlot {
batch_index: event.batch_index,
evt: event.evt,
+ release_ids: Vec::new(),
resolved: (0..item_count).map(|_| None).collect(),
legacy_resolved: event
.legacy_exception_jsons
diff --git a/rust/cymbal/src/modes/processing/stages/resolution/remote/resolver/retry.rs b/rust/cymbal/src/modes/processing/stages/resolution/remote/resolver/retry.rs
index 826b2d8a7e4d..3e5d2750f21e 100644
--- a/rust/cymbal/src/modes/processing/stages/resolution/remote/resolver/retry.rs
+++ b/rust/cymbal/src/modes/processing/stages/resolution/remote/resolver/retry.rs
@@ -23,6 +23,7 @@ use crate::metric_consts::{
REMOTE_RESOLUTION_REROUTE_DEPTH,
};
use crate::types::Exception;
+use uuid::Uuid;
use crate::stages::resolution::remote::{client::RemoteCallError, mux::ResolveItemSession};
@@ -151,7 +152,10 @@ pub(super) async fn resolve_work_item(
};
match decision {
- ItemDecision::Done(exception) => {
+ ItemDecision::Done {
+ exception,
+ release_id,
+ } => {
metrics::counter!(REMOTE_RESOLUTION_REQUESTS, "outcome" => "ok").increment(1);
record_reroute_depth("ok", attempts_used);
return Ok(ResolvedRemoteItem {
@@ -159,6 +163,7 @@ pub(super) async fn resolve_work_item(
exception_slot: work_item.exception_slot,
target: work_item.target,
exception,
+ release_id,
});
}
ItemDecision::Overloaded(message) => {
@@ -276,7 +281,10 @@ fn single_outcome(
#[derive(Debug)]
enum ItemDecision {
- Done(Exception),
+ Done {
+ exception: Exception,
+ release_id: Option<Uuid>,
+ },
Overloaded(String),
Retry {
message: String,
@@ -304,7 +312,16 @@ fn classify_outcome(
format!("invalid_done_payload: failed to parse resolved exception: {err}"),
)
})?;
- Ok(ItemDecision::Done(exception))
+ // An unparseable release id is decoration we can drop, not a reason to fail an
+ // otherwise-resolved item. Empty means the server found no release, or predates
+ // the field.
+ let release_id = (!done.release_id.is_empty())
+ .then(|| Uuid::parse_str(&done.release_id).ok())
+ .flatten();
+ Ok(ItemDecision::Done {
+ exception,
+ release_id,
+ })
}
resolve_outcome::Result::Retry(retry) => {
let retry_after = (retry.retry_after_ms > 0)
@@ -431,16 +448,49 @@ mod tests {
#[test]
fn classify_outcome_parses_done_exception() {
let work_item = work_item(7);
- let outcome = ResolveOutcome {
+ let outcome = done_outcome(&exception("Resolved"), String::new());
+
+ let decision = classify_outcome(&work_item, outcome).expect("done outcome");
+ assert!(matches!(
+ decision,
+ ItemDecision::Done { exception, release_id }
+ if exception.exception_type == "Resolved" && release_id.is_none()
+ ));
+ }
+
+ // An empty `release_id` is what a server with no release bound sends, and what one predating
+ // the field sends for everything; an unparseable one is decoration we drop rather than a
+ // reason to fail an item that resolved.
+ #[test]
+ fn classify_outcome_takes_the_release_id_and_tolerates_a_bad_one() {
+ let release_id = Uuid::now_v7();
+ let cases = [
+ (release_id.to_string(), Some(release_id)),
+ (String::new(), None),
+ ("not-a-uuid".to_string(), None),
+ ];
+
+ for (wire_value, expected) in cases {
+ let decision = classify_outcome(
+ &work_item(7),
+ done_outcome(&exception("Resolved"), wire_value.clone()),
+ )
+ .expect("done outcome");
+ let ItemDecision::Done { release_id, .. } = decision else {
+ panic!("expected done decision");
+ };
+ assert_eq!(release_id, expected, "release_id wire value {wire_value:?}");
+ }
+ }
+
+ fn done_outcome(exception: &Exception, release_id: String) -> ResolveOutcome {
+ ResolveOutcome {
id: 7,
result: Some(resolve_outcome::Result::Done(Done {
- resolved_exception_json: serde_json::to_vec(&exception("Resolved"))
- .expect("valid exception"),
+ resolved_exception_json: serde_json::to_vec(exception).expect("valid exception"),
+ release_id,
})),
- };
-
- let decision = classify_outcome(&work_item, outcome).expect("done outcome");
- assert!(matches!(decision, ItemDecision::Done(exc) if exc.exception_type == "Resolved"));
+ }
}
#[test]
diff --git a/rust/cymbal/src/modes/processing/types/exception_event.rs b/rust/cymbal/src/modes/processing/types/exception_event.rs
index 0b212f34b901..7ebdeb527057 100644
--- a/rust/cymbal/src/modes/processing/types/exception_event.rs
+++ b/rust/cymbal/src/modes/processing/types/exception_event.rs
@@ -52,9 +52,12 @@ pub struct Parsed {
pub(crate) client_fingerprint: Option<String>,
pub(crate) legacy_order_exception_list: Option<ExceptionList>,
pub(crate) legacy_order_resolved: Option<ExceptionList>,
- /// The release resolved from the event's `$release_id` or mobile app metadata, if any. Set by
- /// `EventReleaseResolver` and emitted as `$exception_release` at `into_resolved`.
+ /// The release the event resolves to, if any. Set by `EventReleaseResolver` and emitted as
+ /// `$exception_release` at `into_resolved`.
pub(crate) event_release: Option<ReleaseRecord>,
+ /// Releases the resolution service bound to this event's symbol sets, as ids. Set when
+ /// resolution completes and used only as the fallback source for `event_release`.
+ pub(crate) symbol_set_release_ids: Vec<Uuid>,
}
#[derive(Debug, Clone)]
@@ -64,8 +67,7 @@ pub struct ResolvedMetadata {
pub messages: Vec<String>,
pub functions: Vec<String>,
pub handled: bool,
- /// The single release the event resolves to, from its `$release_id` or mobile app metadata.
- /// Emitted as `$exception_release`.
+ /// The single release the event resolves to. Emitted as `$exception_release`.
pub release: Option<ReleaseInfo>,
}
@@ -74,13 +76,15 @@ impl ResolvedMetadata {
exception_list: &ExceptionList,
event_release: Option<&ReleaseRecord>,
) -> Self {
+ let release = event_release.map(|release| release.to_info());
+
Self {
sources: exception_list.get_unique_sources(),
types: exception_list.get_unique_types(),
messages: exception_list.get_unique_messages(),
functions: exception_list.get_unique_functions(),
handled: exception_list.get_is_handled(),
- release: event_release.map(ReleaseRecord::to_info),
+ release,
}
}
}
@@ -243,6 +247,14 @@ impl ExceptionEvent<Parsed> {
self.state.event_release = release;
}
+ pub(crate) fn set_symbol_set_release_ids(&mut self, ids: Vec<Uuid>) {
+ self.state.symbol_set_release_ids = ids;
+ }
+
+ pub(crate) fn symbol_set_release_ids(&self) -> &[Uuid] {
+ &self.state.symbol_set_release_ids
+ }
+
pub(crate) fn into_resolved(self) -> ExceptionEvent<Resolved> {
let metadata = ResolvedMetadata::from_exception_list(
&self.exception_list,
@@ -607,6 +619,7 @@ impl TryFrom<AnyEvent> for ExceptionEvent<Parsed> {
legacy_order_exception_list,
legacy_order_resolved: None,
event_release: None,
+ symbol_set_release_ids: Vec::new(),
},
})
}
@@ -741,31 +754,13 @@ mod tests {
id: Uuid::now_v7(),
team_id: 42,
hash_id: hash_id.to_string(),
- created_at: chrono::DateTime::from_timestamp(0, 0).unwrap(),
+ created_at: chrono::Utc::now(),
version: "1.2.3".to_string(),
project: "my-app".to_string(),
metadata: None,
}
}
- #[test]
- fn event_release_populates_the_singular_release() {
- // The event-level release (from `$release_id` or mobile app metadata) is the sole source of
- // `$exception_release`; it does not depend on any frame carrying a release.
- let metadata = ResolvedMetadata::from_exception_list(
- &ExceptionList::default(),
- Some(&release_record("hash-abc")),
- );
- assert!(metadata.release.is_some());
- }
-
- #[test]
- fn missing_event_release_leaves_the_release_unset() {
- // Without an event-level release there is nothing to emit; there is no per-frame fallback.
- let metadata = ResolvedMetadata::from_exception_list(&ExceptionList::default(), None);
- assert!(metadata.release.is_none());
- }
-
#[test]
fn exception_release_emitted_only_when_a_release_resolves() {
let issue = Issue {
diff --git a/rust/cymbal/src/modes/resolution/README.md b/rust/cymbal/src/modes/resolution/README.md
index 0bf1bdfd2caa..a578bcba1c6d 100644
--- a/rust/cymbal/src/modes/resolution/README.md
+++ b/rust/cymbal/src/modes/resolution/README.md
@@ -45,7 +45,7 @@ events ──HTTP─────▶│ cymbal
The contract is intentionally split across two streams:
-- **`Resolve`** is bidirectional work traffic. The caller sends independent `ResolveItem`s, each with a per-stream id, `team_id`, serialized exception JSON, JSON `metadata` bytes, and an item deadline. The server emits an `Accepted` outcome when it admits an item, then exactly one terminal `ResolveOutcome` with the same id: `Done`, `Retry`, or `Error`.
+- **`Resolve`** is bidirectional work traffic. The caller sends independent `ResolveItem`s, each with a per-stream id, `team_id`, serialized exception JSON, JSON `metadata` bytes, and an item deadline. The server emits an `Accepted` outcome when it admits an item, then exactly one terminal `ResolveOutcome` with the same id: `Done`, `Retry`, or `Error`. A `Done` carries the resolved exception JSON plus a `release_id`: the newest release bound to a symbol set the item's frames reference. It is empty when no referenced symbol set has a release, and on servers that predate the field, so callers treat empty as "no release".
- **`Subscribe`** is endpoint freshness, draining, and soft load state. The cymbal-side `EndpointPool` opens one long-lived stream per pod and treats the latest `LoadEvent` as a freshness snapshot plus an `in_flight` / `max_in_flight` routing bias. `LoadEvent` does not carry overload state or suggested batch sizing.
`Error.kind` is the shared control-flow surface:
diff --git a/rust/cymbal/src/modes/resolution/service/resolve.rs b/rust/cymbal/src/modes/resolution/service/resolve.rs
index c9b341af054a..57f2f16d04ea 100644
--- a/rust/cymbal/src/modes/resolution/service/resolve.rs
+++ b/rust/cymbal/src/modes/resolution/service/resolve.rs
@@ -1,3 +1,4 @@
+use std::collections::HashSet;
use std::sync::Arc;
use std::time::{Duration, Instant};
@@ -6,6 +7,7 @@ use serde_json::json;
use tokio::sync::mpsc;
use tonic::{Status, Streaming};
use tracing::{debug, warn};
+use uuid::Uuid;
use crate::error::UnhandledError;
use crate::langs::native::DebugImage;
@@ -152,7 +154,11 @@ async fn process_item(
match tokio::time::timeout(deadline, resolve_item(&stage, &item)).await {
Ok(Ok(resolved)) => (
resolve_outcome::Result::Done(Done {
- resolved_exception_json: resolved,
+ resolved_exception_json: resolved.exception_json,
+ release_id: resolved
+ .release_id
+ .map(|id| id.to_string())
+ .unwrap_or_default(),
}),
"done",
"ok",
@@ -230,26 +236,60 @@ enum ItemFailure {
Unhandled(String),
}
+struct ResolvedItem {
+ exception_json: Vec<u8>,
+ release_id: Option<Uuid>,
+}
+
async fn resolve_item(
stage: &LocalResolutionContext,
item: &ResolveItem,
-) -> Result<Vec<u8>, ItemFailure> {
+) -> Result<ResolvedItem, ItemFailure> {
let exception: Exception = serde_json::from_slice(&item.exception_json)
.map_err(|e| ItemFailure::InvalidPayload(format!("invalid exception_json: {e}")))?;
let debug_images = debug_images_from_metadata(&item.metadata)?;
- let resolved = resolve_one_exception(stage.clone(), item.team_id, exception, debug_images)
- .await
- .map_err(|e| match e {
- ResolveOneError::Overloaded => {
- ItemFailure::Overloaded("symbol-resolution limiter unavailable".to_string())
- }
- ResolveOneError::Unhandled(err) => ItemFailure::Unhandled(err),
- })?;
+ // The refs come off the raw frames, so the release lookup is independent of symbolication and
+ // runs alongside it rather than after.
+ let symbol_set_refs = symbol_set_refs(&exception, &debug_images);
+ let release_fut = async {
+ stage
+ .symbol_resolver
+ .latest_release_id(item.team_id, &symbol_set_refs)
+ .await
+ .map_err(|err| ItemFailure::Unhandled(err.to_string()))
+ };
+ let resolve_fut = async {
+ resolve_one_exception(stage.clone(), item.team_id, exception, debug_images)
+ .await
+ .map_err(|e| match e {
+ ResolveOneError::Overloaded => {
+ ItemFailure::Overloaded("symbol-resolution limiter unavailable".to_string())
+ }
+ ResolveOneError::Unhandled(err) => ItemFailure::Unhandled(err),
+ })
+ };
+ let (resolved, release_id) = tokio::try_join!(resolve_fut, release_fut)?;
+
+ Ok(ResolvedItem {
+ exception_json: serde_json::to_vec(&resolved)
+ .map_err(|e| ItemFailure::Unhandled(format!("serialize resolved exception: {e}")))?,
+ release_id,
+ })
+}
- serde_json::to_vec(&resolved)
- .map_err(|e| ItemFailure::Unhandled(format!("serialize resolved exception: {e}")))
+/// Distinct symbol sets this exception's frames resolve against, in first-seen order. A frame
+/// without a ref (an interpreted language, or a native frame no debug image covers) contributes
+/// nothing, so an exception with no refs at all skips the release lookup entirely.
+fn symbol_set_refs(exception: &Exception, debug_images: &[DebugImage]) -> Vec<String> {
+ let mut seen = HashSet::new();
+ exception
+ .get_raw_frame()
+ .iter()
+ .filter_map(|frame| frame.symbol_set_ref(debug_images))
+ .filter(|set_ref| seen.insert(set_ref.clone()))
+ .collect()
}
fn debug_images_from_metadata(metadata: &[u8]) -> Result<Vec<DebugImage>, ItemFailure> {
diff --git a/rust/cymbal/tests/common/mod.rs b/rust/cymbal/tests/common/mod.rs
index 6fa923d4740d..51e33208dfde 100644
--- a/rust/cymbal/tests/common/mod.rs
+++ b/rust/cymbal/tests/common/mod.rs
@@ -258,6 +258,7 @@ fn done_outcome(item: &ResolveItem) -> ResolveOutcome {
id: item.id,
result: Some(resolve_outcome::Result::Done(Done {
resolved_exception_json: item.exception_json.clone(),
+ release_id: String::new(),
})),
}
}
diff --git a/rust/cymbal/tests/resolution_service_tests.rs b/rust/cymbal/tests/resolution_service_tests.rs
index c3c8f00c7074..fe4f8afd9be9 100644
--- a/rust/cymbal/tests/resolution_service_tests.rs
+++ b/rust/cymbal/tests/resolution_service_tests.rs
@@ -1,6 +1,6 @@
use std::sync::{
atomic::{AtomicBool, AtomicUsize, Ordering},
- Arc,
+ Arc, Mutex,
};
use std::time::Duration;
@@ -24,11 +24,14 @@ use futures::StreamExt;
use tokio::sync::Semaphore;
use tonic::transport::{Channel, Server};
use tonic::Request;
+use uuid::Uuid;
#[derive(Default)]
struct FakeResolver {
fail_unhandled: bool,
resolved_frames: Vec<Frame>,
+ release_id: Option<Uuid>,
+ release_refs: Arc<Mutex<Vec<String>>>,
}
#[async_trait]
@@ -62,6 +65,15 @@ impl SymbolResolver for FakeResolver {
) -> Result<String, ResolveError> {
unreachable!("fake resolver does not need dart name resolution for these tests")
}
+
+ async fn latest_release_id(
+ &self,
+ _team_id: TeamId,
+ symbol_set_refs: &[String],
+ ) -> Result<Option<Uuid>, UnhandledError> {
+ *self.release_refs.lock().expect("release refs poisoned") = symbol_set_refs.to_vec();
+ Ok(self.release_id)
+ }
}
struct SlowResolver {
@@ -316,8 +328,8 @@ async fn raw_frames_are_resolved_into_done_payload() {
let mut resolver_frame = sample_resolved_frame(&raw_frame);
resolver_frame.frame_id = raw_frame.frame_id(123, 99, &[]);
let service = make_service(FakeResolver {
- fail_unhandled: false,
resolved_frames: vec![resolver_frame],
+ ..Default::default()
});
let mut exc = raw_exception("RuntimeError");
exc.stack = Some(Stacktrace::Raw {
@@ -342,6 +354,53 @@ async fn raw_frames_are_resolved_into_done_payload() {
assert_eq!(frames, vec![expected_wire_frame]);
}
+#[tokio::test]
+async fn the_release_rides_the_outcome_and_is_looked_up_by_distinct_symbol_set_ref() {
+ let release_id = Uuid::from_u128(7);
+ let release_refs = Arc::new(Mutex::new(Vec::new()));
+ let service = make_service(FakeResolver {
+ release_id: Some(release_id),
+ release_refs: release_refs.clone(),
+ ..Default::default()
+ });
+ let mut exc = raw_exception("RuntimeError");
+ // Two frames from one chunk and one from another: the lookup sees each ref once.
+ exc.stack = Some(Stacktrace::Raw {
+ frames: vec![
+ js_raw_frame("chunk-a"),
+ js_raw_frame("chunk-a"),
+ js_raw_frame("chunk-b"),
+ ],
+ });
+
+ let outcomes = resolve_items(service, vec![make_item(1, &exc)]).await;
+ let resolve_outcome::Result::Done(done) = outcome_result(&outcomes[0]) else {
+ panic!("expected Done outcome, got {:?}", outcomes[0]);
+ };
+
+ assert_eq!(done.release_id, release_id.to_string());
+ assert_eq!(
+ *release_refs.lock().expect("release refs poisoned"),
+ vec!["chunk-a".to_string(), "chunk-b".to_string()]
+ );
+}
+
+#[tokio::test]
+async fn no_bound_release_leaves_the_outcome_release_id_empty() {
+ let service = make_service(FakeResolver::default());
+ let mut exc = raw_exception("RuntimeError");
+ exc.stack = Some(Stacktrace::Raw {
+ frames: vec![sample_raw_frame()],
+ });
+
+ let outcomes = resolve_items(service, vec![make_item(1, &exc)]).await;
+ let resolve_outcome::Result::Done(done) = outcome_result(&outcomes[0]) else {
+ panic!("expected Done outcome, got {:?}", outcomes[0]);
+ };
+
+ assert!(done.release_id.is_empty());
+}
+
#[tokio::test]
async fn bidi_resolve_stream_emits_outcomes_as_items_complete_out_of_order() {
let active = Arc::new(AtomicUsize::new(0));
@@ -507,6 +566,19 @@ fn java_exception_for_overload() -> Exception {
}
}
+fn js_raw_frame(chunk_id: &str) -> RawFrame {
+ let json = serde_json::json!({
+ "platform": "web:javascript",
+ "filename": "a.js",
+ "function": "f",
+ "in_app": true,
+ "lineno": 1,
+ "colno": 1,
+ "chunk_id": chunk_id,
+ });
+ serde_json::from_value(json).expect("valid raw frame")
+}
+
fn sample_raw_frame() -> RawFrame {
let json = serde_json::json!({
"platform": "web:javascript",