-
Notifications
You must be signed in to change notification settings - Fork 8
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
End of Form Error Handling #1560
Conversation
…d is handled by callers
…ready been processed
@snopoke There's an edge case causing test failures and I can't figure out how to best handle it. Could I get your thoughts? From what I understand, the situation is:
But with this PR, the non-match throws an exception. A solution for this is: if we encounter a match "miss", we check if the remaining steps are datums for new case ids. If true, we don't throw an exception. However, I don't see a way to know if the step is associated with creating a new case_id. But similarly, if the last step is |
I did some debugging and it took a while to figure out what was going on but I think your suggestion to check that the current step we're processing is a This might be a challenge to implement without completely refactoring that method since we don't actually track which step is the current one. Personally I've wanted to refactor that function many times but never managed to push it all the way through. |
@@ -106,6 +107,17 @@ public void rebuildSessionFromFrame(MenuSession menuSession, CaseSearchHelper ca | |||
} | |||
} | |||
} | |||
if (currentStep == null && processedStepsCount != steps.size()) { | |||
StringJoiner optionsIDJoiner = new StringJoiner(", ", "[", "]"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot believe StringJoiner
exists since 1.8 and I never heard of it. Pretty handy.
@@ -106,6 +107,17 @@ public void rebuildSessionFromFrame(MenuSession menuSession, CaseSearchHelper ca | |||
} | |||
} | |||
} | |||
if (currentStep == null && processedStepsCount != steps.size()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you push that in its own method? rebuildSessionFromFrame
is quite long already
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
… valid option In the steps, there can be situations such as case id generation datum where it is not intended to be processed. This leads to a non-match between the step and available option. In this case, the exception should not be thrown.
…ndled here "claim_command..." commands are not processed here so these not being matched should not throw an error.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1560 +/- ##
============================================
- Coverage 70.15% 70.15% -0.01%
- Complexity 1993 2009 +16
============================================
Files 252 252
Lines 7781 7833 +52
Branches 699 713 +14
============================================
+ Hits 5459 5495 +36
- Misses 2054 2069 +15
- Partials 268 269 +1 ☔ View full report in Codecov by Sentry. |
Thank you for taking the time to look into this for me @snopoke. I ended up tracking what steps were processed, and checking that the remaining unprocessed steps contained a |
@@ -101,11 +106,15 @@ public void rebuildSessionFromFrame(MenuSession menuSession, CaseSearchHelper ca | |||
for (StackFrameStep step : steps) { | |||
if (step.getId().equals(options[i].getCommandID())) { | |||
currentStep = String.valueOf(i); | |||
processedSteps.add(step); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I notice this loop has no break statement in it. I think it should since I can't think of a scenario where more than one step would match.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, should this line be moved out of the for loop since only the last matching step would be 'processed'. I don't think it should be possible for multiple steps to match but I can't prove that.
Bumping for review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing blocking.
@@ -101,11 +106,15 @@ public void rebuildSessionFromFrame(MenuSession menuSession, CaseSearchHelper ca | |||
for (StackFrameStep step : steps) { | |||
if (step.getId().equals(options[i].getCommandID())) { | |||
currentStep = String.valueOf(i); | |||
processedSteps.add(step); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, should this line be moved out of the for loop since only the last matching step would be 'processed'. I don't think it should be possible for multiple steps to match but I can't prove that.
src/main/java/org/commcare/formplayer/services/MenuSessionFactory.java
Outdated
Show resolved
Hide resolved
src/main/java/org/commcare/formplayer/services/MenuSessionFactory.java
Outdated
Show resolved
Hide resolved
@snopoke, I couldn't reply to that comment thread
I'm not entirely sure if it's possible either but I see |
Product Description
This PR does two things:
Technical Summary
Jira Ticket
Safety Assurance
Safety story
tested locally, will test on staging
Automated test coverage
Basic end of form navigation tests exists and the response is as expected
QA Plan
no QA
Special deploy instructions
Rollback instructions
Review