mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-01 11:06:50 +08:00
feat(logging): Emit a setup error when a restricted keys are used for logging default keys (#5185)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
use error_stack::ResultExt;
|
||||
use router::{
|
||||
configs::settings::{CmdLineConf, Settings},
|
||||
core::errors::{ApplicationError, ApplicationResult},
|
||||
@ -24,7 +25,8 @@ async fn main() -> ApplicationResult<()> {
|
||||
&conf.log,
|
||||
router_env::service_name!(),
|
||||
[router_env::service_name!(), "actix_server"],
|
||||
);
|
||||
)
|
||||
.change_context(ApplicationError::ConfigurationError)?;
|
||||
|
||||
logger::info!("Application started [{:?}] [{:?}]", conf.server, conf.log);
|
||||
|
||||
@ -39,8 +41,7 @@ async fn main() -> ApplicationResult<()> {
|
||||
.expect("Failed to create the server");
|
||||
let _ = server.await;
|
||||
|
||||
Err(ApplicationError::from(std::io::Error::new(
|
||||
std::io::ErrorKind::Other,
|
||||
"Server shut down",
|
||||
Err(error_stack::Report::from(ApplicationError::from(
|
||||
std::io::Error::new(std::io::ErrorKind::Other, "Server shut down"),
|
||||
)))
|
||||
}
|
||||
|
||||
@ -116,7 +116,8 @@ pub async fn start_web_server(
|
||||
let web_server = actix_web::HttpServer::new(move || {
|
||||
actix_web::App::new().service(Health::server(state.clone(), service.clone()))
|
||||
})
|
||||
.bind((server.host.as_str(), server.port))?
|
||||
.bind((server.host.as_str(), server.port))
|
||||
.change_context(ApplicationError::ConfigurationError)?
|
||||
.workers(server.workers)
|
||||
.run();
|
||||
let _ = web_server.handle();
|
||||
|
||||
@ -8,6 +8,7 @@ use analytics::{opensearch::OpenSearchConfig, ReportConfig};
|
||||
use api_models::{enums, payment_methods::RequiredFieldInfo};
|
||||
use common_utils::ext_traits::ConfigExt;
|
||||
use config::{Environment, File};
|
||||
use error_stack::ResultExt;
|
||||
#[cfg(feature = "email")]
|
||||
use external_services::email::EmailSettings;
|
||||
use external_services::{
|
||||
@ -33,7 +34,7 @@ use storage_impl::config::QueueStrategy;
|
||||
use crate::analytics::AnalyticsConfig;
|
||||
use crate::{
|
||||
core::errors::{ApplicationError, ApplicationResult},
|
||||
env::{self, logger, Env},
|
||||
env::{self, Env},
|
||||
events::EventsConfig,
|
||||
};
|
||||
|
||||
@ -722,7 +723,8 @@ impl Settings<SecuredSecret> {
|
||||
let environment = env::which();
|
||||
let config_path = router_env::Config::config_path(&environment.to_string(), config_path);
|
||||
|
||||
let config = router_env::Config::builder(&environment.to_string())?
|
||||
let config = router_env::Config::builder(&environment.to_string())
|
||||
.change_context(ApplicationError::ConfigurationError)?
|
||||
.add_source(File::from(config_path).required(false))
|
||||
.add_source(
|
||||
Environment::with_prefix("ROUTER")
|
||||
@ -736,13 +738,12 @@ impl Settings<SecuredSecret> {
|
||||
.with_list_parse_key("connector_request_reference_id_config.merchant_ids_send_payment_id_as_connector_request_id"),
|
||||
|
||||
)
|
||||
.build()?;
|
||||
.build()
|
||||
.change_context(ApplicationError::ConfigurationError)?;
|
||||
|
||||
serde_path_to_error::deserialize(config).map_err(|error| {
|
||||
logger::error!(%error, "Unable to deserialize application configuration");
|
||||
eprintln!("Unable to deserialize application configuration: {error}");
|
||||
ApplicationError::from(error.into_inner())
|
||||
})
|
||||
serde_path_to_error::deserialize(config)
|
||||
.attach_printable("Unable to deserialize application configuration")
|
||||
.change_context(ApplicationError::ConfigurationError)
|
||||
}
|
||||
|
||||
pub fn validate(&self) -> ApplicationResult<()> {
|
||||
@ -756,14 +757,18 @@ impl Settings<SecuredSecret> {
|
||||
})?;
|
||||
if self.log.file.enabled {
|
||||
if self.log.file.file_name.is_default_or_empty() {
|
||||
return Err(ApplicationError::InvalidConfigurationValueError(
|
||||
"log file name must not be empty".into(),
|
||||
return Err(error_stack::Report::from(
|
||||
ApplicationError::InvalidConfigurationValueError(
|
||||
"log file name must not be empty".into(),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
if self.log.file.path.is_default_or_empty() {
|
||||
return Err(ApplicationError::InvalidConfigurationValueError(
|
||||
"log directory path must not be empty".into(),
|
||||
return Err(error_stack::Report::from(
|
||||
ApplicationError::InvalidConfigurationValueError(
|
||||
"log directory path must not be empty".into(),
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ use crate::services;
|
||||
pub type RouterResult<T> = CustomResult<T, ApiErrorResponse>;
|
||||
pub type RouterResponse<T> = CustomResult<services::ApplicationResponse<T>, ApiErrorResponse>;
|
||||
|
||||
pub type ApplicationResult<T> = Result<T, ApplicationError>;
|
||||
pub type ApplicationResult<T> = error_stack::Result<T, ApplicationError>;
|
||||
pub type ApplicationResponse<T> = ApplicationResult<services::ApplicationResponse<T>>;
|
||||
|
||||
pub type CustomerResponse<T> =
|
||||
|
||||
Reference in New Issue
Block a user