Enrich external API failure audit metadata

This commit is contained in:
kdletters
2026-05-28 15:42:46 +08:00
parent 2cd2b9704b
commit f1fb92aa29
40 changed files with 315 additions and 152 deletions

View File

@@ -62,6 +62,7 @@ pub(super) async fn generate_square_hole_visual_assets_for_session(
_ => Some(
generate_square_hole_image_data_url(
state,
request_context,
&owner_user_id,
&session_id,
profile_id.as_str(),
@@ -90,6 +91,7 @@ pub(super) async fn generate_square_hole_visual_assets_for_session(
_ => Some(
generate_square_hole_image_data_url(
state,
request_context,
&owner_user_id,
&session_id,
profile_id.as_str(),
@@ -118,6 +120,7 @@ pub(super) async fn generate_square_hole_visual_assets_for_session(
option.image_src = Some(
generate_square_hole_image_data_url(
state,
request_context,
&owner_user_id,
&session_id,
profile_id.as_str(),
@@ -145,6 +148,7 @@ pub(super) async fn generate_square_hole_visual_assets_for_session(
option.image_src = Some(
generate_square_hole_image_data_url(
state,
request_context,
&owner_user_id,
&session_id,
profile_id.as_str(),
@@ -252,6 +256,7 @@ pub(super) async fn regenerate_square_hole_visual_asset_for_work(
work.cover_image_src = Some(
generate_square_hole_image_data_url(
state,
request_context,
owner_user_id.as_str(),
synthetic_session_id.as_str(),
profile_id.as_str(),
@@ -271,6 +276,7 @@ pub(super) async fn regenerate_square_hole_visual_asset_for_work(
work.background_image_src = Some(
generate_square_hole_image_data_url(
state,
request_context,
owner_user_id.as_str(),
synthetic_session_id.as_str(),
profile_id.as_str(),
@@ -301,6 +307,7 @@ pub(super) async fn regenerate_square_hole_visual_asset_for_work(
option.image_src = Some(
generate_square_hole_image_data_url(
state,
request_context,
owner_user_id.as_str(),
synthetic_session_id.as_str(),
profile_id.as_str(),
@@ -331,6 +338,7 @@ pub(super) async fn regenerate_square_hole_visual_asset_for_work(
option.image_src = Some(
generate_square_hole_image_data_url(
state,
request_context,
owner_user_id.as_str(),
synthetic_session_id.as_str(),
profile_id.as_str(),
@@ -380,6 +388,7 @@ pub(super) async fn regenerate_square_hole_visual_asset_for_work(
async fn generate_square_hole_image_data_url(
state: &AppState,
request_context: &RequestContext,
owner_user_id: &str,
session_id: &str,
profile_id: &str,
@@ -389,10 +398,12 @@ async fn generate_square_hole_image_data_url(
size: &str,
failure_context: &str,
) -> Result<String, AppError> {
let settings = require_openai_image_settings(state)?.with_external_api_audit_context(
Some(owner_user_id.to_string()),
Some(profile_id.to_string()),
);
let settings = require_openai_image_settings(state)?
.with_external_api_audit_context(
request_context,
Some(owner_user_id.to_string()),
Some(profile_id.to_string()),
);
let http_client = build_openai_image_http_client(&settings)?;
let generated = create_openai_image_generation(
&http_client,