fix: simple form zombie state when submission fails#190
fix: simple form zombie state when submission fails#190mushrafmim wants to merge 2 commits intoOpenNSW:mainfrom
Conversation
Summary of ChangesHello @mushrafmim, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves an issue where failed external form submissions would leave tasks in an unclear state, offering no feedback or recovery options to the user. By introducing an explicit Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new SUBMISSION_FAILED state to handle cases where form submission to an external service fails, preventing tasks from getting stuck in a "zombie" state. The changes include updating the backend state machine, adding logic to transition to the new state upon submission failure, and updating the frontend to display a warning banner to the user, allowing them to retry. The test suite has been extended to cover the new state and its transitions. My review identifies one area for improvement in error handling to make the fix more robust against edge cases, which has been retained as a high-severity comment.
Summary
When a trader submits a form and the external submission URL is unreachable or returns an error, the task previously stayed silently in
INITIALIZEDorDRAFTstate — no indication of the failed attempt, and a blind retry could send a duplicate to the external system. This PR introduces an explicitSUBMISSION_FAILEDplugin state so the failure is surfaced at the workflow level and the user can cleanly retry from the portal.Type of Change
Changes Made
Backend (
internal/task/plugin/simple_form.go)SubmissionFailedplugin state constant ("SUBMISSION_FAILED")simpleFormFSMSubmitFailedinternal FSM action ("SUBMIT_FORM_FAILED")submissionFailedErrsentinel error type — distinguishes an HTTP-level failure (where the remote system may have already recorded the data) from earlier validation failures, so only the former drives the failure transitionNewSimpleFormFSMwith 5 new edges:INITIALIZED/DRAFT + SUBMIT_FORM_FAILED → SUBMISSION_FAILED [IN_PROGRESS]SUBMISSION_FAILED + DRAFT_FORM → DRAFT [IN_PROGRESS]SUBMISSION_FAILED + SUBMIT_FORM_COMPLETE → SUBMITTED [COMPLETED]SUBMISSION_FAILED + SUBMIT_FORM_AWAIT_OGA → OGA_ACKNOWLEDGED [IN_PROGRESS]ExecutedetectssubmissionFailedErrviaerrors.Asand transitions toSUBMISSION_FAILEDbefore returning the error responsesubmitHandlerwraps thesendFormSubmissionerror insubmissionFailedErrresolveFormDatareturns saved local-store form data when inSUBMISSION_FAILEDstate so the user sees their previously submitted data on retryFrontend (
portals/apps/trader-app/src/plugins/SimpleForm.tsx)TraderFormwhenpluginState === 'SUBMISSION_FAILED', prompting the user to review and resubmitTests (
internal/task/plugin/fsm_test.go)SUBMISSION_FAILED, all three recovery paths, and two invalid transitions from that stateTesting
Testing Strategy
To reproduce and verify the fix manually:
SimpleFormwith a submission URL (e.g. the Phytosanitary Certificate form).FORM_SUBMISSION_FAILEDerror.Before this fix: Step 5 would show the form with no banner and no indication that a submission was ever attempted.
Checklist
Related Issues
Fixes #117
Additional Notes
The
submissionFailedErrsentinel is intentionally package-private — it is only used withinsimple_form.goto signalExecuteabout the specific failure origin. Validation errors (schema parse, traverse, form data parse) do not use this type and therefore do not trigger theSUBMISSION_FAILEDtransition, leaving the task in its current state so the user can correct and resubmit without the task entering a failure state unnecessarily.