kobotoolbox / kpi

kpi is the (frontend) server for KoboToolbox. It includes an API for users to access data and manage their forms, question library, sharing settings, create reports, and export data.
https://www.kobotoolbox.org
GNU Affero General Public License v3.0
131 stars 177 forks source link

Fix "mismatched labels and translations" export failure #4978

Closed jnm closed 3 months ago

jnm commented 3 months ago

Checklist

  1. [x] If you've added code that should be tested, add tests
  2. [ ] If you've changed APIs, update (or create!) the documentation
  3. [x] Ensure the tests pass
  4. [x] Make sure that your code lints and that you've followed our coding style
  5. [x] Write a title and, if necessary, a description of your work suitable for publishing in our release notes
  6. [x] Mention any related issues in this repository (as #ISSUE) and in other repositories (as kobotoolbox/other#ISSUE)
  7. [ ] Open an issue in the docs if there are UI/UX changes

Description

Resolves a bug that affected multi-language forms using select_one_from_file or select_multiple_from_file

Notes

This includes a fix to formpack that prevents the file column, created when formpack.utils.expand_content.expand_content() processes select_*_from_file questions, from being transformed into media::file and treated as a translatable column, which it is not (!)

Additionally, this change calls formpack.utils.bugfix.repair_file_column_content_in_place() to undo the damage to existing Asset.content and AssetVersion.version_content. This repair utility is invoked in two places:

  1. on the Asset and all associated AssetVersions when kobo.apps.reports.report_data.build_formpack() is called, which happens during report and export generation;
  2. on the Asset content alone when a GET request is sent to the asset detail endpoint.

Related issues

kobotoolbox/formpack#323 (fix upon which this PR depends) kobotoolbox/formpack#322 (detailed explanation of problem) kobotoolbox/formpack#321 (PR which introduced the bug)