From 9c4499a91c639a1d7dd9d6678d4cfff5d5bd3dbe Mon Sep 17 00:00:00 2001 From: Philip Lykke Carlsen Date: Tue, 7 Nov 2023 21:59:33 +0100 Subject: [PATCH] Log errors during configuration validation --- rust-connector-sdk/src/default_main.rs | 30 ++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/rust-connector-sdk/src/default_main.rs b/rust-connector-sdk/src/default_main.rs index fe877ad1..5b6fe9d4 100644 --- a/rust-connector-sdk/src/default_main.rs +++ b/rust-connector-sdk/src/default_main.rs @@ -608,15 +608,33 @@ where .await .and_then(JsonResponse::into_value) .map_err(|e| match e { - SchemaError::Other(_) => ( - StatusCode::INTERNAL_SERVER_ERROR, - Json(ValidateErrors::UnableToBuildSchema), - ), + SchemaError::Other(err) => { + tracing::error!( + meta.signal_type = "log", + event.domain = "ndc", + event.name = "Unable to build schema", + name = "Unable to build schema", + body = %err, + error = true, + ); + ( + StatusCode::INTERNAL_SERVER_ERROR, + Json(ValidateErrors::UnableToBuildSchema), + ) + } })?; - let resolved_config_bytes = serde_json::to_vec(&configuration).map_err(|e| { + let resolved_config_bytes = serde_json::to_vec(&configuration).map_err(|err| { + tracing::error!( + meta.signal_type = "log", + event.domain = "ndc", + event.name = "Unable to serialize validated configuration", + name = "Unable to serialize validated configuration", + body = %err, + error = true, + ); ( StatusCode::INTERNAL_SERVER_ERROR, - Json(ValidateErrors::JsonEncodingError(e.to_string())), + Json(ValidateErrors::JsonEncodingError(err.to_string())), ) })?; let resolved_configuration = general_purpose::STANDARD.encode(resolved_config_bytes);