Correctly patch MAX_ASSET_UPLOAD_FILE_SIZE_IN_MB

Hi all
Please can someone confirm for me what is the official/correct way to patch the value of MAX_ASSET_UPLOAD_FILE_SIZE_IN_MB ?

I noticed in edx-platform/cms/envs/common.py that a value of 20MB is hard coded in there. (source) and this seems to correlate directly to my web interface:

But if I look in my installation under .local/share/tutor/env/apps/openedx/settings/cms/production.py then there is a default value of MAX_ASSET_UPLOAD_FILE_SIZE_IN_MB = 100
Then slightly below that is another line of the same config:
MAX_ASSET_UPLOAD_FILE_SIZE_IN_MB = 1024 which is the value from the old patch I used to use in Palm:

name: maxuploadsize
version: 1.0.0
patches:
        openedx-cms-production-settings: |
                MAX_ASSET_UPLOAD_FILE_SIZE_IN_MB = 1024

(I also tried under openedx-cms-common-settings patch with the same results)

If I look in my CMS container it also shows a 20MB value so it seems that my old patch is doing nothing in this regard

app@c4f8536d9f10:~/edx-platform$ cat cms/envs/common.py | grep MAX_ASSET
MAX_ASSET_UPLOAD_FILE_SIZE_IN_MB = 20
MAX_ASSET_UPLOAD_FILE_SIZE_URL = ""

What am I missing?

The actual file used to load the django settings should be in cms/envs/tutor/production.py.

You can load a django shell to be 100% sure about what value is actually loaded by the service, something like

# Inside the CMS container
python manage.py cms shell
>>> from django.conf import settings
>>> settings.MAX_ASSET_UPLOAD_FILE_SIZE_IN_MB

In addition, the upload size is also limited by the caddy service, from what I’m seeing in the source code it’s limited to 250MB without the option to override it. You may try to copy that rule and use a more specific path to circumvent the limit using the caddyfile-cms patch.

Thanks for the feedback @MoisesGonzalezS

If I check the values inside production.py then I see values of 100MB + 1024MB

cat cms/envs/tutor/production.py | grep MAX_ASSET_UPLOAD_FILE_SIZE_IN_MB
MAX_ASSET_UPLOAD_FILE_SIZE_IN_MB = 100
MAX_ASSET_UPLOAD_FILE_SIZE_IN_MB = 1024

If I run the manage.py commands in the CMS container it report 1024MB

>>> from django.conf import settings
>>> settings.MAX_ASSET_UPLOAD_FILE_SIZE_IN_MB
1024

I am familiar with the Caddy modifications needed, but in this case it looks like the web interface still reports maximum is 20MB which matches the value in cms/envs/common.py so it looks like something must have changed at some point rendering previous patches non-functional

Can anyone test modifying their max upload file size setting to confirm if they have the same result?

As far as I can tell its 100% not a Caddy directive that’s responsible for this limit.

It seems to me that the file cms/envs/common.py in the CMS container is the authoritative value and the value in cms/envs/tutor/production.py is completely ignored by the platform. I’ve been unable to determine which patch can successfully modify the value in common.py

Manually editing the value in the common.py file in the container does not work either as the changes do not survive a restart, eg if I edit the file like sed -i 's/MAX_ASSET_UPLOAD_FILE_SIZE_IN_MB = 20/MAX_ASSET_UPLOAD_FILE_SIZE_IN_MB = 1024/' /edx-platform/cms/envs/common.py then it does modify the value, but restarting the container resets it to 20MB.

I’ve tried patches in:

openedx-cms-common-settings
openedx-cms-production-settings
openedx-common-settings
openedx-common-assets-settings

I’ve added to the (cms/lms).env.yml files
I’ve added to the production.py file under .local/share/tutor/env/apps/openedx/settings/(cms/lms)

There is no way I can find to modify the default 20MB limit in common.py

At long last (I think) I’ve arrived at a conclusive answer.

The 20MB value is an MFE specific value in the frontend-app-authoring component.

In the file ModalDropzone.jsx#L18 the value is read from constants.js#L55:
export const UPLOAD_FILE_MAX_SIZE = 20 * 1024 * 1024; // 100mb
here the comment says 100mb even though the value hard-coded here is 20mb, I guess maintainer forgot to update the comment :slight_smile:

I still haven’t figured out if/how this is patchable with plugins, but for now at least I’ve just disabled the Django waffle flag contentstore.new_studio_mfe.use_new_files_uploads_page which reverts to the old version of the file uploads page, this correctly displays the value of MAX_ASSET_UPLOAD_FILE_SIZE_IN_MB which is in my old patch.

It would probably be ideal if UPLOAD_FILE_MAX_SIZE could read the value of MAX_ASSET_UPLOAD_FILE_SIZE_IN_MB instead of fragmenting values across multiple places, but this is a bit beyond my scope…