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

Error handling fixes #203

Closed
wants to merge 8 commits into from
Closed

Conversation

jasonbornsteinMOOV
Copy link
Contributor

@jasonbornsteinMOOV jasonbornsteinMOOV commented Sep 29, 2023

Changes

Fix to error handling for events

Why Are Changes Being Made

Better logging for error handling.
Better support for events written without encryption to be decrypted.

The specific flow used to see this is the http://localhost:8080/shards/{shardName}/files/{fileID} endpoint, which produces an unencrypted event to pass internally for achgateway to consume, where the consumer expects the event to be encrypted.

@jasonbornsteinMOOV jasonbornsteinMOOV changed the title Cacnel ACH transaction fixes Error handling fixes Sep 29, 2023
@@ -268,7 +268,8 @@ func (fr *FileReceiver) processMessage(msg *pubsub.Message) error {
// Optionally decode and decrypt message
data, err = compliance.Reveal(fr.transformConfig, data)
if err != nil {
return logger.LogErrorf("unable to reveal event: %v", err).Err()
logger.LogErrorf("unable to reveal event: %v", err)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know if this is going to be a workaround or a hack to get past where the event used in cancelling a transfer comes in without needing to be decrypted, or if this is going to be a permanent solution.

Choose a reason for hiding this comment

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

Looks like there are different event types for ACHFile and CancelACHFile. Wouldn't it be better to check the type, and not trying to decrypt CancelACHFile events. That way true decryption errors could fail as they should. You could just move the decryption down to line 307 or 315.

Copy link
Contributor Author

@jasonbornsteinMOOV jasonbornsteinMOOV Oct 4, 2023

Choose a reason for hiding this comment

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

we could try to check the event type. it would require reading first (to get the event type), possibly failing because it needs to be revealed, an(d then reading again). but it shouldn't depend on the event type. it should just be that what we got was either encrypted or it wasn't, and we have to either reveal it or read it first to find out.

Choose a reason for hiding this comment

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

I see, I did not notice that. If we need to get something working soon, I am ok with this approach. However, I think that we should create a ticket to fix this in a better way. It looks to me like the achgateway can receive events over http and over kafka. The kafka events come from ach-orchestrator and are encrypted, the http events are in the clear. After receiving the event, they are passed to code that processes both types and trys to decrypt them. The decryption always fails for the events received over http.

The decryption should be moved into the kafka specific components (configurable) so that decrypted events get delivered to the common code in all cases. This would fix the achgateway correctly in all cases.

Choose a reason for hiding this comment

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

I see, I did not notice that. If we need to get something working soon, I am ok with this approach. However, I think that we should create a ticket to fix this in a better way. It looks to me like the achgateway can receive events over http and over kafka. The kafka events come from ach-orchestrator and are encrypted, the http events are in the clear. After receiving the event, they are passed to code that processes both types and trys to decrypt them. The decryption always fails for the events received over http.

The decryption should be moved into the kafka specific components (configurable) so that decrypted events get delivered to the common code in all cases. This would fix the achgateway correctly in all cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's a good point. Can you raise a Linear card for that change?

Copy link
Contributor Author

@jasonbornsteinMOOV jasonbornsteinMOOV Oct 6, 2023

Choose a reason for hiding this comment

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

@wadearnold
Copy link
Member

I am confused as to: What were you trying to do?

What where you expecting and what did you get?

Where is the new test case for the new behavior?

This looks like a hack.

@jasonbornsteinMOOV
Copy link
Contributor Author

jasonbornsteinMOOV commented Oct 2, 2023

I am confused as to: What were you trying to do?

What where you expecting and what did you get?

Where is the new test case for the new behavior?

This looks like a hack.

It is a bit of a hack - at least to prompt discussion.
I'm trying to get the cancel event working for a manual ACH transfer getting cancelled.

Test case is still in progress.

I probably need to update the description a bit more.

@jasonbornsteinMOOV jasonbornsteinMOOV marked this pull request as draft October 2, 2023 15:54
@jasonbornsteinMOOV jasonbornsteinMOOV marked this pull request as ready for review October 4, 2023 19:41
Copy link

@rowland66 rowland66 left a comment

Choose a reason for hiding this comment

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

See comment.

@@ -268,7 +268,8 @@ func (fr *FileReceiver) processMessage(msg *pubsub.Message) error {
// Optionally decode and decrypt message
data, err = compliance.Reveal(fr.transformConfig, data)
if err != nil {
return logger.LogErrorf("unable to reveal event: %v", err).Err()
logger.LogErrorf("unable to reveal event: %v", err)

Choose a reason for hiding this comment

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

Looks like there are different event types for ACHFile and CancelACHFile. Wouldn't it be better to check the type, and not trying to decrypt CancelACHFile events. That way true decryption errors could fail as they should. You could just move the decryption down to line 307 or 315.

@rowland66 rowland66 self-requested a review October 5, 2023 18:29
Copy link

@rowland66 rowland66 left a comment

Choose a reason for hiding this comment

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

Approved with comment.

@adamdecaf adamdecaf closed this Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants