From fd4c74b4170122f008b6ebddccb45872b025776c Mon Sep 17 00:00:00 2001 From: Sebastian Zivota Date: Fri, 15 Nov 2024 10:33:26 +0100 Subject: [PATCH] feat: Add Unsupported variant to CacheError and ObjectFileStatus This is the part of https://github.com/getsentry/symbolicator/pull/1541 that just introduces the variants but doesn't yet produce them anywhere. --- crates/symbolicator-js/src/interface.rs | 1 + .../src/symbolication/module_lookup.rs | 1 + .../src/caching/cache_error.rs | 16 ++++++++++++++++ crates/symbolicator-service/src/types.rs | 7 +++++++ 4 files changed, 25 insertions(+) diff --git a/crates/symbolicator-js/src/interface.rs b/crates/symbolicator-js/src/interface.rs index 4ba77fd3e..12888f029 100644 --- a/crates/symbolicator-js/src/interface.rs +++ b/crates/symbolicator-js/src/interface.rs @@ -142,6 +142,7 @@ impl From for JsScrapingResult { ), CacheError::DownloadError(details) => (JsScrapingFailureReason::DownloadError, details), CacheError::Malformed(details) => (JsScrapingFailureReason::Other, details), + CacheError::Unsupported(details) => (JsScrapingFailureReason::Other, details), CacheError::InternalError => (JsScrapingFailureReason::Other, String::new()), }; diff --git a/crates/symbolicator-native/src/symbolication/module_lookup.rs b/crates/symbolicator-native/src/symbolication/module_lookup.rs index 70c1dbb07..cc4b0ea87 100644 --- a/crates/symbolicator-native/src/symbolication/module_lookup.rs +++ b/crates/symbolicator-native/src/symbolication/module_lookup.rs @@ -47,6 +47,7 @@ pub fn object_file_status_from_cache_entry(cache_entry: &CacheEntry) -> Ob } Err(CacheError::Timeout(_)) => ObjectFileStatus::Timeout, Err(CacheError::Malformed(_)) => ObjectFileStatus::Malformed, + Err(CacheError::Unsupported(_)) => ObjectFileStatus::Unsupported, Err(CacheError::InternalError) => ObjectFileStatus::Other, } } diff --git a/crates/symbolicator-service/src/caching/cache_error.rs b/crates/symbolicator-service/src/caching/cache_error.rs index 3eed01620..d86a0209e 100644 --- a/crates/symbolicator-service/src/caching/cache_error.rs +++ b/crates/symbolicator-service/src/caching/cache_error.rs @@ -38,6 +38,14 @@ pub enum CacheError { /// during symcache conversion #[error("malformed: {0}")] Malformed(String), + /// The object is of a type that cannot be used for the symbolication task it was + /// requested for. + /// + /// This is currently only used when we try to symbolicate a .NET event with a Windows + /// PDB file. A tracking issue in `symbolic` for supporting this case is + /// [here](https://github.com/getsentry/symbolic/issues/871). + #[error("unsupported: {0}")] + Unsupported(String), /// An unexpected error in symbolicator itself. /// /// This variant is not intended to be persisted to or read from caches. @@ -64,6 +72,7 @@ impl CacheError { pub(super) const PERMISSION_DENIED_MARKER: &'static [u8] = b"permissiondenied"; pub(super) const TIMEOUT_MARKER: &'static [u8] = b"timeout"; pub(super) const DOWNLOAD_ERROR_MARKER: &'static [u8] = b"downloaderror"; + pub(super) const UNSUPPORTED_MARKER: &'static [u8] = b"unsupported"; /// Writes error markers and details to a file. /// @@ -99,6 +108,10 @@ impl CacheError { file.write_all(Self::DOWNLOAD_ERROR_MARKER).await?; file.write_all(details.as_bytes()).await?; } + CacheError::Unsupported(details) => { + file.write_all(Self::UNSUPPORTED_MARKER).await?; + file.write_all(details.as_bytes()).await?; + } CacheError::InternalError => { unreachable!("this was already handled above"); } @@ -134,6 +147,9 @@ impl CacheError { } else if let Some(raw_message) = bytes.strip_prefix(Self::MALFORMED_MARKER) { let err_msg = utf8_message(raw_message); Some(Self::Malformed(err_msg.into_owned())) + } else if let Some(raw_message) = bytes.strip_prefix(Self::UNSUPPORTED_MARKER) { + let err_msg = utf8_message(raw_message); + Some(Self::Unsupported(err_msg.into_owned())) } else if bytes.is_empty() { Some(Self::NotFound) } else { diff --git a/crates/symbolicator-service/src/types.rs b/crates/symbolicator-service/src/types.rs index 4e72c96ee..1ac4c82cc 100644 --- a/crates/symbolicator-service/src/types.rs +++ b/crates/symbolicator-service/src/types.rs @@ -147,6 +147,12 @@ pub enum ObjectFileStatus { FetchingFailed, /// Downloading or processing the file took too long. Timeout, + /// The file could not be used for the purpose for which it was requested. + /// + /// This is currently only used when we try to symbolicate a .NET event with a Windows + /// PDB file. A tracking issue in `symbolic` for supporting this case is + /// [here](https://github.com/getsentry/symbolic/issues/871). + Unsupported, /// An internal error while handling this image. Other, } @@ -161,6 +167,7 @@ impl ObjectFileStatus { ObjectFileStatus::Malformed => "malformed", ObjectFileStatus::FetchingFailed => "fetching_failed", ObjectFileStatus::Timeout => "timeout", + ObjectFileStatus::Unsupported => "unsupported", ObjectFileStatus::Other => "other", } }