diff --git a/server-rs/crates/api-server/src/error_reports.rs b/server-rs/crates/api-server/src/error_reports.rs index dc6cb6805..677ea781a 100644 --- a/server-rs/crates/api-server/src/error_reports.rs +++ b/server-rs/crates/api-server/src/error_reports.rs @@ -182,13 +182,12 @@ pub async fn create_error_report( .await .map_err(internal_store_error)?; let digest = format!("{:x}", Sha256::digest(&archive)); - let key_segments = vec!["error-reports".to_string(), "v1".to_string()]; let response = oss .put_object( state.editor_oss_http_client(), OssPutObjectRequest { prefix: LegacyAssetPrefix::AgcErrorReports, - path_segments: key_segments, + path_segments: error_report_oss_path_segments(), file_name: format!("{}.zip", stored.batch_id), content_type: Some("application/zip".to_string()), access: OssObjectAccess::Private, @@ -372,6 +371,10 @@ fn internal_store_error(error: String) -> AppError { AppError::from_status(StatusCode::INTERNAL_SERVER_ERROR).with_message(error) } +fn error_report_oss_path_segments() -> Vec { + vec!["error-reports".to_string(), "v1".to_string()] +} + pub(crate) fn build_error_report_archive( events: &[Event], user_description: Option<&str>, @@ -1040,6 +1043,11 @@ mod tests { assert!(error.contains("events.jsonl")); } + #[test] + fn error_report_oss_path_uses_only_uuid_filename_segment() { + assert_eq!(error_report_oss_path_segments(), ["error-reports", "v1"]); + } + #[test] fn sanitize_report_text_redacts_credentials_and_paths() { assert_eq!(