Skip to content

Conversation

@lindsay-stevens
Copy link
Contributor

Closes #115

  • the form attachment upload endpoint now returns a json object representing attributes of the file, rather than a generic status message {"success": True}
  • set a content-type header for form attachments, in the same way as for submission attachments, since both seem to require it when Central uses S3 file storage
    • it seems webforms errors out if no content-type is set, but enketo is OK
  • also in test_client.py change the print() calls to basic non-none assertions since staging now has quite a lot of data which means those print calls are very noisy.

What has been done to verify that this works as intended?

Added unit test to check the content-type change, ran integration tests to check generally. Opened forms created before the change (enketo OK, webforms errored) and after the change (enketo OK, webforms different probably unrelated error - details in #115).

Why is this the best possible solution? Were any other approaches considered?

This follows the attachment handling for submission attachments, which seems appropriate since it appears Central treats these attachment types in a similar way (in regards to S3 storage etc).

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

The API change should allow pyodk to upload forms with attachments with Central 2025.1 (or later). The content-type change should allow forms with attachments uploaded via pyodk to work with webforms.

I'm not aware of workarounds or fixes for file attachments (submissions or forms) that have inaccurate content-types saved for them (sending the same file again doesn't seem to overwrite).

Do we need any specific form for testing your changes? If so, please attach one.

The tests include the required files / data etc.

Does this change require updates to documentation? If so, please file an issue here and include the link below.

The form attachment upload method is not directly exposed by the pyodk API so it would not require a docs update.

Before submitting this PR, please make sure you have:

  • included test cases for core behavior and edge cases in tests
  • run python -m unittest and verified all tests pass
  • run ruff format pyodk tests and ruff check pyodk tests to lint code
  • verified that any code or assets from external sources are properly credited in comments

- the form attachment upload endpoint now returns a json object
  representing attributes of the file, rather than a generic
  status message {"success": True}
- set a content-type header for form attachments, in the same way
  as for submission attachments, since both seem to require it
  when Central uses S3 file storage
  - it seems webforms errors out if no content-type is set
- also in test_client.py change the print() calls to basic
  non-none assertions since staging now has quite a lot of data
  which means those print calls are very noisy.
- per discussion in getodk/pyodk/getodk#116, the response details
  for an uploaded file are not important, or used in pyodk,
  or exposed in a public pyodk API (fda.upload is private).
Copy link
Member

@lognaturel lognaturel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@lindsay-stevens lindsay-stevens merged commit c20fbd3 into getodk:master Jun 3, 2025
14 checks passed
@lindsay-stevens lindsay-stevens deleted the pyodk-115 branch June 3, 2025 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update form attachment upload endpoint for Central 2025.1

2 participants