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
Bug 1879875: Fix that the Start Pipeline form is not always validated correctly #6673
Conversation
@jerolimov: This pull request references Bugzilla bug 1879875, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker. 3 validation(s) were run on this bug
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/assign @divyanshiGupta |
/kind bug |
@jerolimov I think explicitly setting the revalidation prop to false in I have tested these changes against a few usecases including this one and it seemed to work fine without breaking anything. I will also recommend you to test it against other usecases just to be sure. @rohitkrai03 wdyt? |
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 also investigated this, and I agree with what Christoph as come up with.
I'll wait until EOD Monday before giving this a LGTM. @rohitkrai03 please carve out a moment on Monday to think about this; we need to start closing PRs for the coming Code Freeze so this cannot stay open much longer.
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.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: andrewballantyne, jerolimov, rohitkrai03 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@jerolimov: All pull requests linked via external trackers have merged: Bugzilla bug 1879875 has been moved to the MODIFIED state. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/cherry-pick release-4.5 |
@jerolimov: new pull request created: #6853 In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Fixes:
https://issues.redhat.com/browse/ODC-4364
https://bugzilla.redhat.com/show_bug.cgi?id=1879875
Analysis / Root cause:
When switching between different volume types in start pipeline modal and switching back to a valid volume type the "start" button is still disabled. This happen because Formik does not remove the errors when the user switches from "Empty Directory" to "Secret" and "Empty Directory" again.
The error was set to an invalidate state because the form was validated multiple times with the old and the new form fields.
To check how often and in which order the schema validation was called, you can add a console.warn (for example) output to
volumeTypeSchema
infrontend/packages/dev-console/src/components/pipelines/modals/common/validation-utils.ts
. Like this one:Solution Description:
The problem is based on the order of changes to the form. The Workspace type dropdown uses the DropdownField
onChange
prop to clear the workspace.data. But theDropdownField
itself sets the type field after this change. Both method calls automatically triggers a form validation.See
DropdownField
onChange
:console/frontend/packages/console-shared/src/components/formik-fields/DropdownField.tsx
Lines 34 to 38 in 910f7ce
The form was also additional changed each time when the value of a DropdownField changes:
console/frontend/packages/console-shared/src/components/formik-fields/DropdownField.tsx
Line 17 in 910f7ce
All these calls triggers an asynchronous form validation with old and new data which confuses the form error state.
As solution I added an 3rd parameter to the
setFieldValue
andsetFieldTouched
calls to disable that the fields are marked as "needs revalidation". The revalidation was now only triggered by the already useduseFormikValidationFix
hook.Alternative 1
Component tree:
Also if this is a really small code change this affects the widely used
DropdownField
component.As alternative its also possible to change just the
PiplelineWorkspacesSection
component instead. Instead of using the DropdownField this component could directly use the Dropdown to keep the same UI, but handle the formik state (callingsetFieldValue
inonChange
) itself.@divyanshiGupta WDYT?
Alternative 2
When starting with the analyse of this issue, I expected that the problem cause is that the data was removed and the errors for removed data wasn't re-validated. My initial idea was then to not save the sub-data (config / secretMap) in one data field and use different sub-keys instead.
This also fixes that the entered data was removed when the user switches between the types. I expected that this is also a (small) issue because we have different issues like ODC-2443 which says that form fields shouldn't be cleared when switching such a type selection.
But after implementing this I noticed that the original issue (could not submit form with Empty Directory after selecting ConfigMap) still exists. This also requires this code change I proposed with this PR here, or the Alternative 1.
The much bigger change looks like this: master...jerolimov:odc-4364-fix-datadrop
@divyanshiGupta WDYT? Should we change this here as well or should we change / fix this after we start 4.7?
Screen shots / Gifs for design review:
Unit test coverage report:
Unchanged
Test setup:
Unchanged
Browser conformance: