补充错误报告 OSS key 回归测试

锁定归档路径只含固定前缀和 UUID 文件名
This commit is contained in:
2026-09-01 16:35:16 +08:00
parent 9843b4d7cb
commit c64dd9ef7a
@@ -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<String> {
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!(