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

Return specific Problem if form version in submission XML is not found #629

Closed
matthew-white opened this issue Sep 30, 2022 · 2 comments · Fixed by #766
Closed

Return specific Problem if form version in submission XML is not found #629

matthew-white opened this issue Sep 30, 2022 · 2 comments · Fixed by #766
Assignees
Labels
enhancement New feature or behavior

Comments

@matthew-white
Copy link
Member

matthew-white commented Sep 30, 2022

From the forum: https://forum.getodk.org/t/central-api-docs-example-submission-xml-issue/39139

If you send submission XML whose version attribute does not match any version of the form, then Backend returns a 404.1 Problem ("Could not find the resource you were looking for."):

// default per-project submission path:
openRosaSubmission('/projects/:projectId/submission', false, (auth, { projectId }, xmlFormId, Forms, version) =>
Forms.getByProjectAndXmlFormId(projectId, xmlFormId, false, version)
.then(getOrNotFound)
.then(ensureDef)

restSubmission('/projects/:projectId/forms/:formId', false, ({ projectId, formId }, Forms, version) =>
Forms.getByProjectAndXmlFormId(projectId, formId, false, version) // TODO: okay so this is exactly the same as the func above..
.then(getOrNotFound)
.then(ensureDef)

However, especially if the user doesn't know about the version attribute or that Backend is searching on it, they might not understand why they're receiving a 404 response and might not know how to proceed. (The user might wonder: Does the URL not match a current endpoint? Is the project ID wrong? The form ID?) I think I've gotten confused around this myself after forgetting to specify the version attribute.

I think it'd be useful to return a specific 404 Problem in this case. I think it'd be useful for the Problem to indicate the project ID + xmlFormId + form version string that Backend is looking for. The forum post mentions the REST endpoint specifically, but I think it'd be useful to update both the REST and OpenRosa endpoints.

CC @lindsay-stevens

@matthew-white matthew-white added enhancement New feature or behavior help wanted labels Sep 30, 2022
@ktuite
Copy link
Member

ktuite commented Sep 30, 2022

Having run into this issue doing various dev work and not knowing/forgetting this was a thing, I support this change!

@matthew-white
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or behavior
Projects
Status: ✅ done
Development

Successfully merging a pull request may close this issue.

2 participants