kobotoolbox / kobocat

Our (backend) server for providing blank forms to Collect and Enketo and for receiving and storing submissions.
BSD 2-Clause "Simplified" License
117 stars 128 forks source link

500 error when a `name` (or `list_name`?) is `model` #486

Open jnm opened 5 years ago

jnm commented 5 years ago

https://www.flowdock.com/app/kobotoolbox/kobo/threads/mq9fgrGgz_zq2UtErE6zV5bhTPV

Exception: xml contains multiple model nodes
  <snip>
  File "onadata/apps/api/viewsets/xform_viewset.py", line 776, in update
    survey = utils.publish_xlsform(request, owner, existing_xform)
  File "onadata/apps/api/tools.py", line 266, in publish_xlsform
    return publish_form(set_form)
  File "onadata/libs/utils/logger_tools.py", line 416, in publish_form
    return callback()
  File "onadata/apps/api/tools.py", line 262, in set_form
    return form.publish(user, existing_xform.id_string)
  File "onadata/apps/main/forms.py", line 326, in publish
    return publish_xls_form(cleaned_xls_file, user, id_string)
  File "onadata/libs/utils/logger_tools.py", line 471, in publish_xls_form
    dd.save()
  File "onadata/apps/viewer/models/data_dictionary.py", line 158, in save
    self._set_uuid_in_xml()
  File "onadata/apps/viewer/models/data_dictionary.py", line 71, in _set_uuid_in_xml
    raise Exception(u"xml contains multiple model nodes")
jnm commented 3 years ago

I think that this check is too coarse: https://github.com/kobotoolbox/kobocat/blob/78133d519f7b7674636c871e3ba5670cd64a7227/onadata/apps/viewer/models/data_dictionary.py#L79-L81

I'm guessing a <model> that's a child (or further descendant) of <instance> is just fine: https://getodk.github.io/xforms-spec/#structure.

I don't know well enough how the XForm specification has evolved over time, and we don't want to break existing forms, but maybe it'd be enough to look for <model> elements only that are the immediate children of <h:head>.

Kalyan-Lama commented 3 years ago

For community reference: https://community.kobotoolbox.org/t/online-validator-is-clean-but-error-message-expecting-value-line-2-column-1-char-1-seen-when-uploading-an-xlsform-in-the-server/18404

Kalyan-Lama commented 1 year ago

Community: https://community.kobotoolbox.org/t/failure-to-deploy-my-project-despite-having-used-the-online-validator/37370

JacquelineMorrissette commented 1 year ago

This issue is blocked by this issue in Enketo: https://github.com/enketo/enketo/issues/1077

jnm commented 1 year ago

@JacquelineMorrissette not everyone uses Enketo. I don't think this is blocked; we could proceed with this change on our end:

look for <model> elements only that are the immediate children of <h:head>

When Enketo gets around to fixing it, great. Until then, people can use Collect.