Unable to download zipped media files

Hi there, I would like to note that I am currently unable to download zipped media files using the latest tag of Kobo, 2.021.24b. The error simply says “Failed…” We manage our own instance of this, and the exports worked well in the previous version we used.

Before our recent upgrade, we were using kobo-install version 3.1.3 and image: 2.020.28
we are now on install v5 and 2.021.24b

Is there something we should have done during the upgrade process? or some specific logs to look to see what is happening with these failed exports?

Thanks!

Edit: Additional details -
we are using Ubuntu 20.04.2 LTS
I have “downgraded” a test instance to Kobo 2.021.24 and the zip media export works there.
For now we will move back to 2.021.24 which seems to work for media exports

So maybe it’s an issue with your upgrade.

We have upgraded several times and generally do not encounter issues, always using the same upgrade methods. Upgrade issues are of course always possible, but we have done this enough to generally know what to expect, and this was out of the ordinary.

“/run.py --upgrade 2.021.24b” pulls all the correct images and starts as expected, though there are many new errors reported through Sentry (that I wont bother with here), not least of which is the media exports zip do not work (but this is not reported in Sentry). Given this is a relatively new tag, I was hoping to gain some insight on what could have potentially caused some regression errors. We found this while comparing the tags/releases: Disable seeking when writing ZIP exports · kobotoolbox/kobocat@a2dbb91 · GitHub and not sure if this may have had some effect. perhaps something is going on with the media sync? Merge pull request #3316 from kobotoolbox/sync-media-on-redeploy · kobotoolbox/kpi@480100f · GitHub

Separately, is it possible for you to briefly explain the naming convention for the tags? We could not easily tell if there was a rhyme or reason for -a vs -b on the tags.

Thanks!

Hi @tolexy, we apologize for the issues after upgrading. Did you happen to run the sync_kobocat_form_media management command in the kpi container after upgrading?

Regarding the tag naming, consecutive letters refer to patched releases:

  • major release: 2.021.24
  • first patched release: 2.021.24a
  • second patched release: 2.021.24b
1 Like

It looks like the sole change in KoBoCAT between 2.021.24 and 2.021.24b is my “Disable seeking…” commit, which you already mentioned:

kobocat$ git log tags/2.021.24..tags/2.021.24b
commit a2dbb91ce6742e0d33b0a2538f7a8b28d855a0fb (tag: 2.021.24b, tag: 2.021.24a, origin/hotfix-zip-exports, hotfix-zip-exports, 2.021.24a, 2.021.24)
Author: John N. Milner <john@tmoj.net>
Date:   Fri Jun 25 21:06:22 2021 -0400

    Disable seeking when writing ZIP exports
    
    This is a hotfix for #475

@tolexy can you confirm the type of storage you are using for user-uploaded attachments? I’m assuming it’s local file storage (and not something like Amazon S3). Thanks!

1 Like

great thanks for the info! I dont think I have seen a ‘c’ patched release, but is this theoretically possible?

I did not run the sync_kobocat_form_media on kpi. I havent had to do that manually before for previous upgrade, but was thinking some sort of sync issue might have been the cause. I will try that in our test env to see what happens. 2.021.24 currently works as expected regarding exports, though I am noticing also that I am unable to upload media files to a form even after adding media::image manually to the xlsform. Might this be related to lack of running the sync command?

Media upload fails with:

NotNullViolation: null value in column “synced_with_backend” violates not-null constraint

@jnm We are indeed using local file storage on this instance so likely not seeking like I was exploring. From the previous reply from Josh, it might be the lack of syncing. Are there other necessary sync commands and are there any potential risks to existing data or data that was added after upgrade but before syncing?

Hi @tolexy, I was mistaken. This particular issue is unrelated to syncing, but you will still need to run the sync command regardless for your form media files (this should be a once-off sync specifically related to this upgrade). The management of form media has now moved from kc to kpi.

1 Like

great thanks for the info on this particular upgrade, will test and run sync

1 Like

@Josh

ok so I figured out somewhat, what was happening. We tried to upgrade right to 2.021.24b. In doing so a migration was run that added the synced_with_backend field to the assetfile model. We then discovered the exporting zipped media from a form would always fail. So we rolled back the version to 2.021.24 but this left the migration for 2.021.24B in place. This of course caused sync_kobocat_media_files to fail as the synced_with_backend field wasnt populated.

I upgraded BACK to 24B, ran the sync_kobocat_media_files and sync_kobocat_xforms. This appeared to work until I realized that the media zip export still did not work. at this point I rolled back to 2.021.24 but then could not upload media files to any forms since there was an extra column in kpi_assetfile. Well, I dropped that extra column since it or any associated code wasnt added until 24b and that was the only migration. At first it seemed to work and i was able to upload media files and export zipped media on 2.021.24 UNTIL I tried to deploy any forms or create and deploy a new form. Then I got the below issue. Any ideas how this may have happened or how to recover from it so I can continue testing/troubleshooting?


I cant for the life of me figure out how to get the form links back. The forms are still there, and can be accessed with existing links I have, but I cannot access directly from KPI…

Again thanks in advance!

Apologies for all the posts! But just wanted to highlight some of the steps.

I managed to solve our initial issue by rolling back to 2.021.24, dropping the extraneous column (synced_with_backend) from kpi_assetfile, and running sync_kobocat_form_media. All appears to be working on our dev env now. However, upgrading from here to 24b still presents the zipped media attachment export error that simply says “Failed…” I will be trying clean installs of 24b in the near future to see what issues may have happened along the way. Thanks and apologies again for the many messages!

Hi @tolexy, thank you for reporting this, sharing your workarounds, and having patience while we fix it. I believe the problem is corrected by:

…which will be included in our 2.021.34 release.

1 Like