Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(events): Connector response masking in clickhouse #3566

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2101406
feat(events): pass connector event ref to handle_response
lsampras Feb 1, 2024
6d487e5
pass connector event ref to handle_response v2
AkshayaFoiger Feb 2, 2024
d060eb5
feat(router): add serde::serialize to res obj
AkshayaFoiger Feb 2, 2024
c86d710
refactor(connector): make event logging optional for connector response
lsampras Feb 3, 2024
f9a0b34
fix(connector): fix serialization errors for connector
lsampras Feb 5, 2024
e1e7929
fix(connector): fix nmi handle response
lsampras Feb 5, 2024
1579fe4
fix(connector): add stripe connector serializing
lsampras Feb 6, 2024
fe2f2ff
fix(connector): fix event_builder not used warning
AkshayaFoiger Feb 6, 2024
20890fa
fix(connector): fix clippy error
AkshayaFoiger Feb 6, 2024
f3ec39a
feat(events): update connector events to use masked response
lsampras Feb 6, 2024
cbed0f9
fix(connector): fix DDL commands
AkshayaFoiger Feb 6, 2024
58d3981
Merge branch 'main' into 3517-featevent_viewer-add-masking-for-connec…
AkshayaFoiger Feb 6, 2024
60588b6
Merge branch 'main' into 3517-featevent_viewer-add-masking-for-connec…
AkshayaFoiger Feb 6, 2024
76e0965
fix(connector): fix clippy error
AkshayaFoiger Feb 6, 2024
45c2624
fix(connector): fix clippy error
AkshayaFoiger Feb 7, 2024
790d97a
Merge branch 'main' into 3517-featevent_viewer-add-masking-for-connec…
AkshayaFoiger Feb 7, 2024
4db99c2
fix(connector): fix clippy error
AkshayaFoiger Feb 7, 2024
a47f878
chore: run formatter
hyperswitch-bot[bot] Feb 7, 2024
e6ec9a0
fix(connector): log nmi refundsync response
AkshayaFoiger Feb 7, 2024
9f682bc
chore: run formatter
hyperswitch-bot[bot] Feb 7, 2024
9dc398e
chore(lints): disable clippy lint
lsampras Feb 8, 2024
14ca64c
fix(connector): remove comment
AkshayaFoiger Feb 9, 2024
9793b82
fix(connectors): update set_response_body
AkshayaFoiger Feb 9, 2024
9ff88bf
fix(connector): mask error response
AkshayaFoiger Feb 12, 2024
c53dc38
fix(connector): fix clippy error
AkshayaFoiger Feb 13, 2024
3b75184
refactor(events): set_error_response_body()
AkshayaFoiger Feb 13, 2024
c13f826
Merge branch 'main' into 3517-featevent_viewer-add-masking-for-connec…
AkshayaFoiger Feb 13, 2024
ea53568
chore: run formatter
hyperswitch-bot[bot] Feb 13, 2024
dd23059
fix(connector): fix clippy error
AkshayaFoiger Feb 13, 2024
5577ac6
fix(connectors): add set_response_body to template
AkshayaFoiger Feb 13, 2024
529c490
refactor(connector): log deserialization error
AkshayaFoiger Feb 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[target.'cfg(all())']
rustflags = [
"-Funsafe_code",
"-Aclippy::option_map_unit_fn",
"-Wclippy::as_conversions",
"-Wclippy::expect_used",
"-Wclippy::index_refutable_slice",
Expand Down
249 changes: 137 additions & 112 deletions add_connector.md

Large diffs are not rendered by default.

40 changes: 31 additions & 9 deletions connector-template/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use error_stack::{ResultExt, IntoReport};
use masking::ExposeInterface;

use crate::{
events::connector_api_logs::ConnectorEvent,
configs::settings,
utils::{self, BytesExt},
core::{
Expand Down Expand Up @@ -95,12 +96,16 @@ impl ConnectorCommon for {{project-name | downcase | pascal_case}} {
fn build_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please set_response_body() and logging of response

) -> CustomResult<ErrorResponse, errors::ConnectorError> {
let response: {{project-name | downcase}}::{{project-name | downcase | pascal_case}}ErrorResponse = res
.response
.parse_struct("{{project-name | downcase | pascal_case}}ErrorResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;

event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);

Ok(ErrorResponse {
status_code: res.status_code,
code: response.code,
Expand Down Expand Up @@ -194,18 +199,21 @@ impl
fn handle_response(
&self,
data: &types::PaymentsAuthorizeRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<types::PaymentsAuthorizeRouterData,errors::ConnectorError> {
let response: {{project-name | downcase}}::{{project-name | downcase | pascal_case}}PaymentsResponse = res.response.parse_struct("{{project-name | downcase | pascal_case}} PaymentsAuthorizeResponse").change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
types::RouterData::try_from(types::ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
})
}

fn get_error_response(&self, res: Response) -> CustomResult<ErrorResponse,errors::ConnectorError> {
self.build_error_response(res)
fn get_error_response(&self, res: Response, event_builder: Option<&mut ConnectorEvent>) -> CustomResult<ErrorResponse,errors::ConnectorError> {
self.build_error_response(res, event_builder)
}
}

Expand Down Expand Up @@ -251,24 +259,28 @@ impl
fn handle_response(
&self,
data: &types::PaymentsSyncRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<types::PaymentsSyncRouterData, errors::ConnectorError> {
let response: {{project-name | downcase}}:: {{project-name | downcase | pascal_case}}PaymentsResponse = res
.response
.parse_struct("{{project-name | downcase}} PaymentsSyncResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
types::RouterData::try_from(types::ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
})
}

fn get_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
self.build_error_response(res)
self.build_error_response(res, event_builder)
}
}

Expand Down Expand Up @@ -328,12 +340,15 @@ impl
fn handle_response(
&self,
data: &types::PaymentsCaptureRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<types::PaymentsCaptureRouterData, errors::ConnectorError> {
let response: {{project-name | downcase }}::{{project-name | downcase | pascal_case}}PaymentsResponse = res
.response
.parse_struct("{{project-name | downcase | pascal_case}} PaymentsCaptureResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
types::RouterData::try_from(types::ResponseRouterData {
response,
data: data.clone(),
Expand All @@ -344,8 +359,9 @@ impl
fn get_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
self.build_error_response(res)
self.build_error_response(res, event_builder)
}
}

Expand Down Expand Up @@ -401,18 +417,21 @@ impl
fn handle_response(
&self,
data: &types::RefundsRouterData<api::Execute>,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<types::RefundsRouterData<api::Execute>,errors::ConnectorError> {
let response: {{project-name| downcase}}::RefundResponse = res.response.parse_struct("{{project-name | downcase}} RefundResponse").change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
types::RouterData::try_from(types::ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
})
}

fn get_error_response(&self, res: Response) -> CustomResult<ErrorResponse,errors::ConnectorError> {
self.build_error_response(res)
fn get_error_response(&self, res: Response, event_builder: Option<&mut ConnectorEvent>) -> CustomResult<ErrorResponse,errors::ConnectorError> {
self.build_error_response(res, event_builder)
}
}

Expand Down Expand Up @@ -449,18 +468,21 @@ impl
fn handle_response(
&self,
data: &types::RefundSyncRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<types::RefundSyncRouterData,errors::ConnectorError,> {
let response: {{project-name | downcase}}::RefundResponse = res.response.parse_struct("{{project-name | downcase}} RefundSyncResponse").change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
types::RouterData::try_from(types::ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
})
}

fn get_error_response(&self, res: Response) -> CustomResult<ErrorResponse,errors::ConnectorError> {
self.build_error_response(res)
fn get_error_response(&self, res: Response, event_builder: Option<&mut ConnectorEvent>) -> CustomResult<ErrorResponse,errors::ConnectorError> {
self.build_error_response(res, event_builder)
}
}

Expand Down
Loading
Loading