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

Unable to update entity using XLSForm without entity label #551

Closed
matthew-white opened this issue Nov 28, 2023 · 5 comments · Fixed by getodk/central-backend#1053
Closed
Assignees
Labels
backend Requires a change to the API server entities Multiple Encounter workflows

Comments

@matthew-white
Copy link
Member

I have an entity list of trees. I have two forms to update the trees. One form updates the trees's label in addition to properties, while the other only updates properties. In the entities sheet of the XLSForm, the first form has a label column, while the other does not. That's the only difference between the forms (other than settings like form ID and title).

I'm able to use the form that has the label column to update a tree. However, I'm not able to do so with the form that doesn't have the label column. When I submit a submission to that second form, I see an entity.error in the submission feed: "Required parameter dataset missing."

Looking at the submission XML, I see that there is an <entity> field with a dataset attribute. However, the <entity> field is completely empty. (The XML is <entity .../>.)

I know we looked at a similar issue in #527. I'm not sure what the difference is. My theory is that it's the difference between an empty <entity> field and an <entity> field with only whitespace (<entity> </entity>).

URL of the page

Central version shown in version.txt

versions:
15e519a04eefc41049c30d53b6779682f7890764 (v2023.4.0-3-g15e519a)
+70acd3fecd1efb4c887f51447c0d6028e6eba88d client (v2023.4.0-36-g70acd3fe)
+bb6f38259d1cf842854fac8050731658f2ac5977 server (v2023.4.0-41-gbb6f3825)
@matthew-white matthew-white added backend Requires a change to the API server entities Multiple Encounter workflows labels Nov 28, 2023
@github-project-automation github-project-automation bot moved this to 🕒 backlog in ODK Central Nov 28, 2023
@matthew-white
Copy link
Member Author

My theory is that it's the difference between an empty <entity> field and an <entity> field with only whitespace

Another possibility: in the form without a label column in the entities sheet, the meta/entity field is of type unknown, whereas in the form with a label column, it's of type structure.

@ktuite ktuite self-assigned this Nov 29, 2023
@ktuite
Copy link
Member

ktuite commented Nov 29, 2023

this is really weird. i'm struggling to recreate the issue with a test, but uploading the same forms/submissions as you specified, i was able to crash my dev central, so, uh, hmm.

The specific trace looks like this so I'll be able to dig in and figure it out. Likely it's cause of something you mentioned above, of the field type being unknown.

/Users/ktuite/Desktop/code/odk/central-backend/lib/data/entity.js:79
      entity.system.dataset = field.attrs.dataset;
                                          ^

TypeError: Cannot read properties of undefined (reading 'dataset')
    at Readable.<anonymous> (/Users/ktuite/Desktop/code/odk/central-backend/lib/data/entity.js:79:43)
    at Readable.emit (node:events:514:28)
    at Readable.emit (node:domain:489:12)
    at Readable.read (node:internal/streams/readable:539:10)
    at flow (node:internal/streams/readable:1023:34)
    at emitReadable_ (node:internal/streams/readable:604:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:81:21)

Node.js v18.17.0

@matthew-white
Copy link
Member Author

Interesting! I'm able to write a test that throws an error on the same line that you mentioned. I wonder how the update error on staging got past parseSubmissionXml(). 🤔

@matthew-white
Copy link
Member Author

When I create a submission to the trees_update_no_label form on staging, then look at the service logs, I see a similar error. Could it be that parseSubmissionXml() is somehow causing an error, yet also returning a resolved promise?

@ktuite
Copy link
Member

ktuite commented Nov 29, 2023

I was able to reproduce the bug, I just needed to have a different form def in addition to a different submission.

If the <entity> tag in the form def doesn't have any children, it is of type unknown because it has no children (not structural) and no other type (no bind). But the way I was parsing submissions, I only extracted attributes on structural fields.

This wasn't an issue earlier when new entities always had labels, so there was always a child element, which always made it type structure.

In PR getodk/central-backend#1053 I changed the parsing code to not care if the entity tag is unknown or structure... but <entity> possibly being unknown is still a problem for this other issue: #552

@ktuite ktuite moved this from 🕒 backlog to ✏️ in progress in ODK Central Dec 5, 2023
@ktuite ktuite linked a pull request Dec 5, 2023 that will close this issue
2 tasks
@github-project-automation github-project-automation bot moved this from ✏️ in progress to ✅ done in ODK Central Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Requires a change to the API server entities Multiple Encounter workflows
Projects
Status: ✅ done
Development

Successfully merging a pull request may close this issue.

2 participants