Skip to content

Submission version redirect is infinite loop if instance ID is encoded #1251

Description

@matthew-white

For several endpoints for the logical submission, if you specify the instance ID of a submission edit, Backend will redirect to the corresponding submission version endpoint:

https://github.com/getodk/central-backend/blob/e9dba19f064aed63e58ca54530b90bcc018b72d1/lib/resources/submissions.js#L360-L375

For example, on the QA server, there's a submission edit whose instance ID is uuid:adcaefa3-91d7-4770-a49a-1f5607d0f2f3. The instance ID of the root submission version is uuid:4b2b3e15-5675-4baf-9111-1a548cf312cd. When I request https://test.getodk.cloud/v1/projects/414/forms/children_registration/submissions/uuid:adcaefa3-91d7-4770-a49a-1f5607d0f2f3, the redirect happens as expected. However, if the : in the instance ID is encoded, the redirect doesn't happen: https://test.getodk.cloud/v1/projects/414/forms/children_registration/submissions/uuid%3Aadcaefa3-91d7-4770-a49a-1f5607d0f2f3. Instead, I get an ERR_TOO_MANY_REDIRECTS.

I think the issue is that if the instance ID is encoded in originalUrl, then originalUrl does not contain `/submissions/${params.instanceId}`, because params.instanceId is not encoded. In that case, it doesn't complete the replacement, so it ends up redirecting the user to the same originalUrl.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

backendRequires a change to the API server

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions