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

Logic model validation is loose #2208

Closed
mantariksh opened this issue Jun 18, 2021 · 3 comments
Closed

Logic model validation is loose #2208

mantariksh opened this issue Jun 18, 2021 · 3 comments
Assignees
Labels
P2 planned for next 1-2 months react feature blocking

Comments

@mantariksh
Copy link
Contributor

In form logic, specific field types are only compatible with certain specific "condition states", e.g. dropdown fields can only be used with "is equals to" or "is either" conditions.

However, the backend does not enforce this coupling between field types and condition states. It simply accepts any field ID linked to any possible condition state. For example, nothing is stopping the frontend from mistakenly saving a logic unit where an "is greater than" condition is applied to a dropdown field. This introduces risks for the React frontend migration, since sending API calls with the wrong logic unit shape could result in corruption of the database state.

This should be tackled in a few steps:

  1. Check that the current database does not contain any mismatched logic conditions.
  2. Enforce the correct matching of logic conditions to field types in the model layer.
  3. Enforce the correct shape of logic API calls through Joi validation.
@liangyuanruo
Copy link
Contributor

Note: to also watch out for data pollution

@mantariksh
Copy link
Contributor Author

on second thoughts, not clear if Joi validation can be used here, since the Joi validator only has access to the field ID and not the field type, and hence may not be able to check if the corresponding conditions are valid

@yong-jie yong-jie self-assigned this Jun 23, 2021
@r00dgirl r00dgirl added the P2 planned for next 1-2 months label Jun 23, 2021
@karrui
Copy link
Contributor

karrui commented Aug 26, 2021

Closed by #2302

@karrui karrui closed this as completed Aug 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 planned for next 1-2 months react feature blocking
Projects
None yet
Development

No branches or pull requests

5 participants