From bbe9a09f60b8f066c2679b7c9be5dc834747c500 Mon Sep 17 00:00:00 2001 From: Chris Klochek Date: Fri, 16 Oct 2026 16:07:55 -0400 Subject: [PATCH] wip --- crates/symbolicator-service/src/config.rs | 2 +- .../symbolicator/src/endpoints/invoke_tool.rs | 104 ++++++++++++++++++ crates/symbolicator/src/endpoints/mod.rs | 5 + 3 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 crates/symbolicator/src/endpoints/invoke_tool.rs diff --git a/crates/symbolicator-service/src/config.rs b/crates/symbolicator-service/src/config.rs index c75d4b1c8..55a9b81bd 100644 --- a/crates/symbolicator-service/src/config.rs +++ b/crates/symbolicator-service/src/config.rs @@ -49,7 +49,7 @@ pub struct Logging { impl Default for Logging { fn default() -> Self { Logging { - level: LevelFilter::INFO, + level: LevelFilter::TRACE, format: LogFormat::Auto, enable_backtraces: true, } diff --git a/crates/symbolicator/src/endpoints/invoke_tool.rs b/crates/symbolicator/src/endpoints/invoke_tool.rs new file mode 100644 index 000000000..afc96ccef --- /dev/null +++ b/crates/symbolicator/src/endpoints/invoke_tool.rs @@ -0,0 +1,104 @@ +use axum::{ + Json, extract, + response::{IntoResponse, Response}, +}; +use serde::Deserialize; +use std::sync::Arc; +use symbolicator_native::interface::{AttachmentFile, ProcessMinidump, SystemInfo}; +use symbolicator_service::types::ScrapingConfig; +use symbolicator_sources::SourceConfig; +use tracing::info; + +use crate::{ + endpoints::{ResponseError, symbolicate_any::SymbolicationRequest}, + service::{RequestOptions, RequestQueryParams, RequestService, SymbolicationResponse}, +}; + +#[derive(Deserialize)] +pub enum ToolCall { + GetMetadata, +} + +#[derive(Deserialize)] +pub struct ToolRequest { + minidump: SymbolicationRequest, + + #[serde(default)] + sources: Arc<[SourceConfig]>, + + args: ToolCall, +} + +pub async fn invoke_tool( + extract::State(service): extract::State, + extract::Query(params): extract::Query, + extract::Json(body): extract::Json, +) -> Result { + info!("invoke_tool"); + match body.args { + ToolCall::GetMetadata => get_metadata(service, body.minidump, body.sources) + .await + .map(IntoResponse::into_response), + } +} + +async fn get_metadata( + service: RequestService, + req: SymbolicationRequest, + sources: Arc<[SourceConfig]>, +) -> Result, ResponseError> { + let (storage_url, storage_token, rewrite_first_module) = match req { + SymbolicationRequest::Minidump { + storage_url, + storage_token, + rewrite_first_module, + } => (storage_url, storage_token, rewrite_first_module), + SymbolicationRequest::AppleCrashreport { + storage_url, + storage_token, + } => todo!(), + }; + let pm = ProcessMinidump { + platform: None, //? + scope: symbolicator_service::types::Scope::Global, + minidump_file: AttachmentFile::Remote { + storage_url, + storage_token, + }, + sources: sources, + scraping: ScrapingConfig::default(), + rewrite_first_module, + extract_variables: false, + }; + let request_id = service + .process_minidump(pm, RequestOptions::default()) + .unwrap(); + + let r: Result = + match service.get_response(request_id, None).await { + Some(response) => Ok(response), + None => Err("symbolication request did not start".into()), + }; + + let r2 = r.unwrap(); + + match r2 { + SymbolicationResponse::Completed(completed_response) => match *completed_response { + crate::service::CompletedResponse::Native(completed_symbolication_response) => { + completed_symbolication_response + .system_info + .map(|si| Json(si)) + .ok_or(anyhow::anyhow!("no system info").into()) + } + crate::service::CompletedResponse::Js(completed_js_symbolication_response) => todo!(), + crate::service::CompletedResponse::Jvm(completed_jvm_symbolication_response) => todo!(), + }, + SymbolicationResponse::Pending { + request_id, + retry_after, + } => todo!(), + SymbolicationResponse::Failed { message } => todo!(), + SymbolicationResponse::Timeout => todo!(), + SymbolicationResponse::InternalError => todo!(), + } +} diff --git a/crates/symbolicator/src/endpoints/mod.rs b/crates/symbolicator/src/endpoints/mod.rs index 58fbde7a7..434177d89 100644 --- a/crates/symbolicator/src/endpoints/mod.rs +++ b/crates/symbolicator/src/endpoints/mod.rs @@ -4,10 +4,12 @@ use axum::routing::{get, post}; use sentry::integrations::tower::{NewSentryLayer, SentryHttpLayer}; use tower::ServiceBuilder; +use crate::endpoints::invoke_tool::invoke_tool; use crate::service::RequestService; mod applecrashreport; mod error; +mod invoke_tool; mod metrics; mod minidump; mod multipart; @@ -42,6 +44,8 @@ pub fn create_app(service: RequestService) -> Router { .layer(SentryHttpLayer::new().enable_transaction()) .layer(MetricsLayer); + let tool_router = Router::new().route("/invoke_tool", post(invoke_tool)); + // Routes for symbolication requests that don't include large files. These can use a lower // body size limit. let symbolicate_router = Router::new() @@ -71,6 +75,7 @@ pub fn create_app(service: RequestService) -> Router { .merge(symbolicate_router) .merge(large_file_router) .merge(misc_router) + .merge(tool_router) .with_state(service) .layer(middleware) // the healthcheck is last, as it will bypass all the middlewares