Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-82177

Intermittent problem with file uploads: files being uploaded with path '/undefined/' when it should be '/'

XMLWordPrintable

    • MOODLE_402_STABLE, MOODLE_403_STABLE
    • MOODLE_403_STABLE, MOODLE_404_STABLE
    • MDL-82177_403
    • MDL-82177_404
    • Hide

      We need to test all the main ways to get files into Moodle, to ensure there are no regressions, and we need to test this one manually, becuase the Behat tests for file upload, of necessity, have to work by more-or-less faking the user action, rather than performing it through the driven browser.

      The exact bits of Moodle used to test this don't matter. We are just testing the widgets used in these forms.

      File picker form field - upload

      1. Go to the question bank in any course, then 'Import' from the tertiary navigation.
      2. Select 'File format' 'Moodle XML format'.
      3. Click 'Choose a file...' and use the filepicker to upload question/type/essay/tests/fixtures/testquestion.moodle.xml
      4. Verify this completes without errors.
      5. Click 'Import' then 'Continue'.
      6. Verify this completes without errors, and you see 'essay-001' in the question list.

      File picker form field - drag-drop

      (This is a repeat of the previous section, but using drag-drop to do the upload.)

      1. Go to the question bank in any course, then 'Import' from the tertiary navigation.
      2. Select 'File format' 'Moodle XML format'.
      3. Drag and drop question/type/essay/tests/fixtures/testquestion.moodle.xml into the filepicker on the form.
      4. Verify this completes without errors.
      5. Click 'Import' then 'Continue'.
      6. Verify this completes without errors, and you see another 'essay-001' in the question list. (You can tell which is the new one using the timestamps in the 'Created by' column.)

      File manager - upload

      1. Go to any course and turn editing on.
      2. 'Add activity or resource ...' -> 'Folder'
      3. Type any 'Name'
      4. In the 'Files' file manager, click the 'New folder' icon, then 'Create folder'.
      5. Click the 'Add file' icon, and choose any random file on your computer to upload.
      6. Verify the file is added, at the top level without errors.
      7. Click on the 'New folder' folder.
      8. Click the 'Add file' icon, and choose any random file on your computer to upload.
      9. Verify the file is added, in the folder without errors.
      10. Use the icons at the top right to switch the filepicker into a different display mode. Repeat steps 5-9 above in each mode. (In tree view mode, I think the filepicker only lets you add more files at the top level - in any case, this has not changed.)
      11. Click 'Save and display'.
      12. Verify that the contents of the new Folder resource are displayed, matchin what you uploaded.

      File manager - drag-drop

      (This is a repeat of the previous section, but using drag-drop to do the upload.)

      1. Go to any course and turn editing on.
      2. 'Add activity or resource ...' -> 'Folder'
      3. Type any 'Name'
      4. In the 'Files' file manager, click the 'New folder' icon, then 'Create folder'.
      5. Drag and drop any file from your computer into the file manager.
      6. Verify the file is added, at the top level without errors.
      7. Click on the 'New folder' folder.
      8. Drag and drop any file from your computer into the file manager.
      9. Verify the file is added, in the folder without errors.
      10. Use the icons at the top right to switch the filepicker into a different display mode. Repeat steps 5-9 above in each mode. (In tree view mode, I think the filepicker only lets you add more files at the top level - in any case, this has not changed.)
      11. Click 'Save and display'.
      12. Verify that the contents of the new Folder resource are displayed, matchin what you uploaded.
      Show
      We need to test all the main ways to get files into Moodle, to ensure there are no regressions, and we need to test this one manually, becuase the Behat tests for file upload, of necessity, have to work by more-or-less faking the user action, rather than performing it through the driven browser. The exact bits of Moodle used to test this don't matter. We are just testing the widgets used in these forms. File picker form field - upload Go to the question bank in any course, then 'Import' from the tertiary navigation. Select 'File format' 'Moodle XML format'. Click 'Choose a file...' and use the filepicker to upload question/type/essay/tests/fixtures/testquestion.moodle.xml Verify this completes without errors. Click 'Import' then 'Continue'. Verify this completes without errors, and you see 'essay-001' in the question list. File picker form field - drag-drop (This is a repeat of the previous section, but using drag-drop to do the upload.) Go to the question bank in any course, then 'Import' from the tertiary navigation. Select 'File format' 'Moodle XML format'. Drag and drop question/type/essay/tests/fixtures/testquestion.moodle.xml into the filepicker on the form. Verify this completes without errors. Click 'Import' then 'Continue'. Verify this completes without errors, and you see another 'essay-001' in the question list. (You can tell which is the new one using the timestamps in the 'Created by' column.) File manager - upload Go to any course and turn editing on. 'Add activity or resource ...' -> 'Folder' Type any 'Name' In the 'Files' file manager, click the 'New folder' icon, then 'Create folder'. Click the 'Add file' icon, and choose any random file on your computer to upload. Verify the file is added, at the top level without errors. Click on the 'New folder' folder. Click the 'Add file' icon, and choose any random file on your computer to upload. Verify the file is added, in the folder without errors. Use the icons at the top right to switch the filepicker into a different display mode. Repeat steps 5-9 above in each mode. (In tree view mode, I think the filepicker only lets you add more files at the top level - in any case, this has not changed.) Click 'Save and display'. Verify that the contents of the new Folder resource are displayed, matchin what you uploaded. File manager - drag-drop (This is a repeat of the previous section, but using drag-drop to do the upload.) Go to any course and turn editing on. 'Add activity or resource ...' -> 'Folder' Type any 'Name' In the 'Files' file manager, click the 'New folder' icon, then 'Create folder'. Drag and drop any file from your computer into the file manager. Verify the file is added, at the top level without errors. Click on the 'New folder' folder. Drag and drop any file from your computer into the file manager. Verify the file is added, in the folder without errors. Use the icons at the top right to switch the filepicker into a different display mode. Repeat steps 5-9 above in each mode. (In tree view mode, I think the filepicker only lets you add more files at the top level - in any case, this has not changed.) Click 'Save and display'. Verify that the contents of the new Folder resource are displayed, matchin what you uploaded.

      We have found that, in our Moodle site, occasionally, files are getting uploaded with filepath set to '/undefined/' when it should probably be '/'.

      Given that 'undefined' is a thing in JavaScript, this looks like an intermittent but in the FilePicker code.

      If the place being uploaded to is set to not allow subdirectories, then this leads to the file being lost.

      When I say itermittent, on our Moodle site we have had 458931 file upload attempts this year, of which 147 (0.032%) had this problem. So, it is very itermittent, but we found this because one of the lost files was in an exam submission, and that sort of thing makes you worry.

      Some useful queries:

      Problem files that got as far as the files table.

      SELECT component, COUNT(1)
      FROM mdl_files
      WHERE filepath = '/undefined/'
      GROUP BY component
      ORDER BY count(1) DESC
      

      Logs of uploads that went wrong like this:

      SELECT TO_TIMESTAMP(timecreated), *
      FROM mdl_logstore_standard_log
      WHERE eventname = '\core\event\draft_file_added'
      AND other::json->>'filepath' = '/undefined/'
      ORDER BY timecreated DESC
      

      Daily count of successful and failed uploads.

      SELECT DATE_TRUNC('day', TO_TIMESTAMP(timecreated)), COUNT(1), COUNT(other::json->>'filepath' = '/undefined/' OR NULL)
      FROM mdl_logstore_standard_log
      WHERE eventname = '\core\event\draft_file_added'
      GROUP BY DATE_TRUNC('day', TO_TIMESTAMP(timecreated))
      ORDER BY DATE_TRUNC('day', TO_TIMESTAMP(timecreated))
      

      The last two might be Postgres-specific.

      Note that, when this happens, the log entry contains the contenthash of the file that was uploaded, and that file can probalby be retrieved from Moodle's file pool.

        1. MDL-82177_403_upload_1.png
          30 kB
          Angelia Dela Cruz
        2. MDL-82177_403_upload_2.png
          110 kB
          Angelia Dela Cruz
        3. MDL-82177_404_upload_1.png
          90 kB
          Angelia Dela Cruz
        4. MDL-82177_404_upload_2.png
          120 kB
          Angelia Dela Cruz
        5. MDL-82177_main_upload_1.png
          89 kB
          Angelia Dela Cruz
        6. MDL-82177_main_upload_2.png
          121 kB
          Angelia Dela Cruz
        7. MDL-82177_403_fm_dragdrog.webm
          4.77 MB
          Angelia Dela Cruz
        8. MDL-82177_403_fm_upload.webm
          5.58 MB
          Angelia Dela Cruz
        9. MDL-82177_404_fm_dragdrog.webm
          4.81 MB
          Angelia Dela Cruz
        10. MDL-82177_main_fm_dragdrog.webm
          5.67 MB
          Angelia Dela Cruz
        11. MDL-82177_404_fm_upload.webm
          8.05 MB
          Angelia Dela Cruz
        12. MDL-82177_main_fm_upload.webm
          7.51 MB
          Angelia Dela Cruz

            timhunt Tim Hunt
            timhunt Tim Hunt
            Anupama Sarjoshi Anupama Sarjoshi
            Huong Nguyen Huong Nguyen
            Angelia Dela Cruz Angelia Dela Cruz
            Votes:
            6 Vote for this issue
            Watchers:
            15 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours, 38 minutes
                2h 38m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.