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

fix: add guard clause for flow[nodeId] in autoAnswerableOptions #4123

Merged
merged 4 commits into from
Jan 9, 2025

Conversation

RODO94
Copy link
Contributor

@RODO94 RODO94 commented Jan 9, 2025

Running through the session and recreating it locally, we found the issue to be in the autoAnswerableOptions store function.

The received error locally was:
Screenshot 2025-01-09 at 12 05 50

After some logging we found the issue lying in flow[nodeId] being undefined in the Filter function.

@jamdelion and I did find it hard to track why flow[nodeId] could be undefined for a save and return path. We thought it would be due to the node being deleted, but that wouldn't be consistent with the way published routes are handled for save and return flows (with the user always returning to the published flow they left from), so we were stumped here.

Important

What is the root cause of flow[nodeId] being undefined?

Copy link

github-actions bot commented Jan 9, 2025

Removed vultr server and associated DNS entries

@jessicamcinchak
Copy link
Member

jessicamcinchak commented Jan 9, 2025

with the user always returning to the published flow they left from

When resuming, the user returns the most recent published version of their flow, NOT the version they started on/left from. This is handled by what we call a "reconciliation" process. If we let everyone resume to the version of the flow they started from, there wouldn't be a need for reconciliation, but there would be the potential to submit invalid/out-of-date applications if legislation changed over your 28 days.

Therefore, it's valid and expected that their may be a breadcrumb which no longer has an associated node in the flow.

We have a function removeOrphansFromBreadcrumbs which I believe we call before processing submission data, but not on each "continue"/record() (from memory! would need to double check this!).

@RODO94 RODO94 requested a review from jessicamcinchak January 9, 2025 12:53
@RODO94 RODO94 marked this pull request as ready for review January 9, 2025 12:53
Copy link
Member

@jessicamcinchak jessicamcinchak left a comment

Choose a reason for hiding this comment

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

I think this change is correct (automation tests are all passing), but I am a bit confused re-creating session and want to double check my work against what you all did:

@RODO94
Copy link
Contributor Author

RODO94 commented Jan 9, 2025

I think this change is correct (automation tests are all passing), but I am a bit confused re-creating session and want to double check my work against what you all did:

Good catch!

I just tried it now and it didn't work due to this line:

   visitedFns.forEach(([nodeId, _breadcrumb]) => {
      flow[nodeId].edges?.map((edgeId) => {
        if (flow[edgeId].type === TYPES.Answer && flow[edgeId].data?.val) {
          visitedOptionVals.push(flow[edgeId].data.val);
        }
      });
    });

I'll repeat the fix here for flow[nodeId]

@RODO94 RODO94 requested a review from jessicamcinchak January 9, 2025 14:46
Copy link
Member

@jessicamcinchak jessicamcinchak left a comment

Choose a reason for hiding this comment

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

Works as expected now, thanks to both you & @jamdelion for getting to the bottom of this one!

@RODO94 RODO94 merged commit eba45ca into main Jan 9, 2025
12 checks passed
@RODO94 RODO94 deleted the rojo/barnet-ldc-bugfix branch January 9, 2025 15:05
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.

2 participants