Skip to content

Fix: keep source=import signal alive across chunked media uploads#334

Open
level09 wants to merge 2 commits into
mainfrom
fix/import-source-param-survive-chunking
Open

Fix: keep source=import signal alive across chunked media uploads#334
level09 wants to merge 2 commits into
mainfrom
fix/import-source-param-survive-chunking

Conversation

@level09
Copy link
Copy Markdown
Collaborator

@level09 level09 commented May 9, 2026

Summary

PR #312 replaced the request.referrer check on /admin/api/media/chunk with request.form.get(\"source\") == \"import\". Dropzone drops its params option on chunked POSTs, so the form field is missing on every chunk request, import_upload is always False, and in S3 mode the chunk endpoint takes the S3 push + local delete branch. The import ETL then runs and finds no local file:

ValueError: The filename given was either non existent or was a directory
  File \"enferno/data_import/utils/media_import.py\", line 447, in upload_import
    info = exiflib.get_json(filepath)[0]

Every import in S3 mode has been failing since #312 merged.

Fix

Move source=import from Dropzone's params to the URL query string and check request.args instead of request.form. Query params live on the URL and ride along on every chunk POST regardless of how Dropzone shapes the body.

Same security posture as the form-body check — both come from the client. The actual access control is the current_user.has_role(\"Admin\") gate three lines down, which is unchanged.

Test plan

  • Upload a video via the media import tool with FILESYSTEM_LOCAL=False. Confirm the file lands in enferno/media/ locally for ETL, then ends up in S3 after MediaImport.upload().
  • Upload a video via the media import tool with FILESYSTEM_LOCAL=True. Confirm normal local-only behavior still works.
  • Confirm normal (non-import) Dropzone uploads under Bulletin/Actor still go straight to S3 in S3 mode.
  • Confirm a non-admin user can't bypass the extension check by hitting /admin/api/media/chunk?source=import directly (admin role gate still applies).

…oads

PR #312 replaced the referrer-based import_upload detection with a form
field check. Dropzone drops its 'params' option on chunked POSTs, so
request.form.get('source') returns None on every chunk, import_upload is
False, and in S3 mode the chunk endpoint pushes uploads to S3 then
removes the local copy. ETL then has nothing to read locally and every
import fails with 'The filename given was either non existent or was a
directory'.

Move the signal to the URL query string. It rides along on every chunk
POST regardless of how Dropzone shapes the body, with the same security
posture as the form-body check (the admin role gate three lines down is
the actual access control).
@level09 level09 requested a review from apodacaduron as a code owner May 9, 2026 08:22
@level09 level09 self-assigned this May 9, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 9, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c9bf29c4-a7b4-4483-9cd9-47fd7361688c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/import-source-param-survive-chunking

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants