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

IntegrityError null value in column "prefill_plugin" of relation "forms_formvariable" violates not-null constraint #3922

Closed
3 tasks done
LaurensBurger opened this issue Feb 21, 2024 · 2 comments · Fixed by open-formulieren/types#44, open-formulieren/formio-builder#127 or #3951
Assignees
Labels
bug Something isn't working needs-backport Fix must be backported to stable release branch
Milestone

Comments

@LaurensBurger
Copy link
Collaborator

LaurensBurger commented Feb 21, 2024

Product versie / Product version

2.5.x (new form builder)

Omschrijf het probleem / Describe the bug

when copying a form that contains a textfield a 500 occurs.
the cause seems to be:

  "prefill": {
    "plugin": null,
    "attribute": null,
    "identifierRole": "main"
  },

which is included in new textfields. removing this part from the json fixes the issue in the form builder

Tasks

@LaurensBurger LaurensBurger added bug Something isn't working triage Issue needs to be validated. Remove this label if the issue considered valid. labels Feb 21, 2024
@LaurensBurger
Copy link
Collaborator Author

#3467

@sergei-maertens sergei-maertens added the needs-backport Fix must be backported to stable release branch label Feb 22, 2024
@sergei-maertens sergei-maertens added this to the Release 2.5.3 milestone Feb 22, 2024
@joeribekker joeribekker removed the triage Issue needs to be validated. Remove this label if the issue considered valid. label Feb 26, 2024
sergei-maertens added a commit to open-formulieren/types that referenced this issue Feb 27, 2024
… plugin or attribute

null values are okay-ish in the Javascript code, but cause constraint
errors when the component is used to populate a FormVariable in the
backend which does not allow NULL values.
sergei-maertens added a commit to open-formulieren/formio-builder that referenced this issue Feb 27, 2024
…ll properties

null leads to database constraint issues in the backend, the empty
value should just be an empty string.
sergei-maertens added a commit to open-formulieren/formio-builder that referenced this issue Feb 27, 2024
sergei-maertens added a commit to open-formulieren/formio-builder that referenced this issue Feb 27, 2024
…pty value than null

null is not necessarily always an acceptable value for a field that was cleared,
so the select component now takes an optional emptyValue prop that will
be set when the (single) select is cleared. For multi selects, the
empty array as a value still makes sense.
sergei-maertens added a commit to open-formulieren/formio-builder that referenced this issue Feb 27, 2024
…ll properties

null leads to database constraint issues in the backend, the empty
value should just be an empty string.
sergei-maertens added a commit to open-formulieren/formio-builder that referenced this issue Feb 27, 2024
@sergei-maertens
Copy link
Member

I was a bit baffled why this only manifests during copying (and likely import) of a form and not during the normal form editing, but I could find out that the JS actually cleans up these null values when creating the variable, which the backend code does not appear to do:

prefillPlugin: component.prefill?.plugin || '',

While the backend does:

So the backend patch will make this a bit more robust and also add a data/import fix to convert component configurations (again).

sergei-maertens added a commit that referenced this issue Feb 27, 2024
…y values

This applies the same behaviour as what the frontend does.
sergei-maertens added a commit that referenced this issue Feb 28, 2024
…y values

This applies the same behaviour as what the frontend does.
sergei-maertens added a commit that referenced this issue Feb 28, 2024
Re-apply the component conversion operation on existing data, as the
new form builder caused new, corrupt, prefill configuration to be
saved in the backend.

Imports should not be affected, because the existing converter was
still wired up. Form copying was patched in the previous commit to be
a bit more robust, this data migration only exists to tidy up and
remove confusion.
sergei-maertens added a commit to open-formulieren/types that referenced this issue Feb 28, 2024
… plugin or attribute

null values are okay-ish in the Javascript code, but cause constraint
errors when the component is used to populate a FormVariable in the
backend which does not allow NULL values.
sergei-maertens added a commit to open-formulieren/formio-builder that referenced this issue Feb 28, 2024
sergei-maertens added a commit to open-formulieren/formio-builder that referenced this issue Feb 28, 2024
…pty value than null

null is not necessarily always an acceptable value for a field that was cleared,
so the select component now takes an optional emptyValue prop that will
be set when the (single) select is cleared. For multi selects, the
empty array as a value still makes sense.
sergei-maertens added a commit to open-formulieren/formio-builder that referenced this issue Feb 28, 2024
…ll properties

null leads to database constraint issues in the backend, the empty
value should just be an empty string.
sergei-maertens added a commit to open-formulieren/formio-builder that referenced this issue Feb 28, 2024
sergei-maertens added a commit to open-formulieren/formio-builder that referenced this issue Feb 28, 2024
sergei-maertens added a commit to open-formulieren/formio-builder that referenced this issue Feb 28, 2024
…ll properties

null leads to database constraint issues in the backend, the empty
value should just be an empty string.

Backport-of: #127
sergei-maertens added a commit that referenced this issue Feb 28, 2024
…y values

This applies the same behaviour as what the frontend does.
sergei-maertens added a commit that referenced this issue Feb 28, 2024
Re-apply the component conversion operation on existing data, as the
new form builder caused new, corrupt, prefill configuration to be
saved in the backend.

Imports should not be affected, because the existing converter was
still wired up. Form copying was patched in the previous commit to be
a bit more robust, this data migration only exists to tidy up and
remove confusion.
sergei-maertens added a commit that referenced this issue Feb 29, 2024
…y values

This applies the same behaviour as what the frontend does.

Backport-of: #3951
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment