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

MCP-2581 and MCP-2582 Offramp in Error Scenarios #1353

Merged
merged 15 commits into from
Mar 29, 2023

Conversation

hayleymdawson
Copy link
Contributor

@hayleymdawson hayleymdawson commented Mar 28, 2023

What was the problem?

Claims were stuck in the following two error cases

  1. MAS Failed to order the exam
  2. We did not order an exam, and failed to upload the PDF due to BIP CE api error

Associated tickets or Slack threads:

How does this fix it?

Claims are now offramped in the above two cases. (See MCP tickets or github issue)

How to test this PR

Run End to End Tests

I have left some review comments on this one, because there's some things that other devs probably care about.

@github-actions
Copy link

github-actions bot commented Mar 28, 2023

Test Results

159 tests  ±0   159 ✔️ ±0   3m 33s ⏱️ +13s
  54 suites ±0       0 💤 ±0 
  54 files   ±0       0 ±0 

Results for commit 35a06cc. ± Comparison against base commit 5f4d50d.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Mar 28, 2023

JaCoCo Test Coverage

File Coverage [81.43%] 🍏
MasCompletionStatus.java 100% 🍏
AppConfig.java 100% 🍏
MockMasConfig.java 98.09% 🍏
MasIntegrationRoutes.java 97.04% 🍏
FilesApiController.java 96.18% 🍏
MasProcessingService.java 84.02% 🍏
SaveToDbServiceImpl.java 78.57%
MasIntegrationProcessors.java 56.83%
MockMasController.java 41.08%
Total Project Coverage 77.43%

@hayleymdawson hayleymdawson changed the title DRAFT - offramp if cannot order exam, offramp if no order and pdf upload fails, trying to code collapse MCP-2581 and MCP-2582 Offramp in Error Scenarios Mar 28, 2023
@@ -157,6 +157,13 @@ public void setOffRampReason(Claim claimWithOffRamp) {
Optional<ClaimSubmissionEntity> claimSubmission =
claimSubmissionRepository.findFirstByReferenceIdAndIdTypeOrderByCreatedAtDesc(
claimWithOffRamp.getCollectionId(), claimWithOffRamp.getIdType());
if (claimSubmission.isEmpty()) {
log.info(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before Yoom asks, yes this is info not error. There are cases we offramp and this doesn't exist yet. When i collapsed the MasIntegration routes for offramping I found that out.

MasCompletionStatus completionStatus = MasCompletionStatus.of(origin, sufficient);
String offRampError = exchange.getProperty("offRampError", String.class);
// Update our database with offramp reason.
if (offRampError != null) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

OffRampError is our key here on properties to know if we're offramping or not.

.to(ENDPOINT_ACCESS_ERR)
.setProperty("offRampError", constant("Sufficiency cannot be determined."))
.setProperty("sourceRoute", constant("assessorError"))
.log("Assessor Error. Off-ramping claim")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ENDPOINT_ACCESS_ERR was very close to what I needed from ENDPOINT_OFFRAMP_ERROR and in the interest of not causing too many camel routes and making the code harder, it's been collapsed and what wasn't contained moved here.

.setProperty("offRampError", constant(pdfFailError))
.setProperty("sourceRoute", constant(rfdRouteId))
.to(ENDPOINT_OFFRAMP_ERROR)
.stop()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

stop is now explicit to ensure that the last masComplete after the catch doesn't run.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should also allow future ENDPOINT_MAS_COMPLETE error handling to stand independently of this try catch as needed.

// Wiretap does NOT let camel work as expected when placed directly inside doCatch()
// Thus it is broken out here, in the interest of letting normal flow/control happen.
from(ENDPOINT_OFFRAMP_ERROR)
.wireTap(ENDPOINT_NOTIFY_AUDIT) // Send error notification to slack
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 realize I often call stop() explicitly rather than relying on this strange behavior. I think that would be easier for devs to follow in the future. And if camel ever makes that work the way that it seems it should.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just to clarify, the right call would be wireTap but due to the redhat issue, we should use stop() in the meantime?

Copy link

Choose a reason for hiding this comment

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

Not quite but I will sync with you in a huddle to explain. :) easier i think

.doCatch(BipException.class)
// Mas Complete Processing code expects this to be the body of the message
.setBody(simple("${exchangeProperty.payload}"))
// Wiretap will cause no code to execute after the end of the try. Intentional here.
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 wanted to not rely on the wiretap side-effect behavior here which stops processing, but i'd have to make an entirely new route just to contain the wiretap in a non offramp scenario and somehow pass the onprepare the right variables differently.
Due to time I commented that I am relying on the strange behavior here. (This case execution did not change in this ticket, i just made endDoCatch() end which is more correct in this case even with wiretap involved).

@hayleymdawson hayleymdawson marked this pull request as ready for review March 28, 2023 16:46
@hayleymdawson hayleymdawson self-assigned this Mar 28, 2023
Copy link
Contributor

@alan-amida alan-amida left a comment

Choose a reason for hiding this comment

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

I personally don't see anything objectionable here, but I also don't know what's in the businesses' head like some others do. The code looks sound. I'll let others comment on design.

Also this is the thing Hayley is talking about with respect to Camel wiretap causing doCatch()s to fail:
https://access.redhat.com/solutions/6749521

You need an account to view the whole thing, but otherwise, it's there, it's known, and RedHat are the only ones so far who have an article about it. Good find, @hayleymdawson

@anthonyvelazquez anthonyvelazquez requested review from anthonyvelazquez and removed request for anthonyvelazquez March 29, 2023 12:30
@hayleymdawson hayleymdawson merged commit f19f8cf into develop Mar 29, 2023
@hayleymdawson hayleymdawson deleted the MCP-2581-Cannot-Order-Exam branch March 29, 2023 13:55
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.

None yet

4 participants