Skip to content

Conversation

Ajay-Satish-01
Copy link

Context

There is a limit set on the maximum API request body size. That limit is currently hardcoded to 1mb.

Proposed solution

Added configurable maximum API request body size

Related issues

#916

Has this been tested?

Yes

  • 👍 yes, I added tests to the test suite
  • 💭 no, because this PR is a draft and still needs work
  • 🙅 no, because this is not relevant here
  • 🙋 no, because I need help

Screenshots / Screencasts

Copy link
Contributor

github-actions bot commented Sep 6, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@Ajay-Satish-01
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Sep 6, 2025
Copy link
Collaborator

@fflorent fflorent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First of all, thank you for your first contribution and addressing that issue! 🙏

Here are few comments on my side.
Please note that my remarks are those of a regular contributor of the project, but I have no authority at the contrary of Grist Labs employees who approve the code to merge.

maxUploadSizeAttachment?: number;

// Max allowed size for API request bodies, in bytes; 0 or omitted for unlimited.
maxApiRequestBodySize?: number;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This object is used to pass environment settings values to the client.

I don't see this property used anywhere. Do you intend to use it client-side?

function getApiRequestBodyLimit(): string {
const limitMB = Number(process.env.GRIST_MAX_API_REQUEST_BODY_MB);
return limitMB > 0 ? `${limitMB}mb` : '1mb'; // Default to 1mb if not set or invalid
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same logic as in the FlexServer, right?

I guess this could somehow be factorized. I see that attachEarlyEndpoints() is passed the gristServer property (which is the instance of FlexServer), I guess this class could be added a public readonly property that could be read here. Do you think it would make sense?

Also there exists an appSettings variable in FlexServer, that helps to parse the env variables correctly with the readInt function that is passed a AppSettingQueryNumber. This way, you could use a line like this:

yourProperty = appSettings.section('<section name>').flag('<flag name>').readInt({
  ....
});

The <section name> and <flag name> is up to you.
For the section name, these names preexists: access, assistant, attachmentStores, boot, docApi, externalStorage, features, history, integrations, locale, log, login, proxy, telemetry, templates, tutorials.
You can create another one (I don't feel like a relevant one can be reused)

For the flag name, you may use a name that describe the variable (maybe the same name as for the property?).

Copy link
Collaborator

@fflorent fflorent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Ajay-Satish-01!

It looks like there are many noises to your last commit, related to code formating.

I don't think we apply such rules in the project lint configuration (we use eslint).

Could you remove the formating changes please? 🙏

@Ajay-Satish-01
Copy link
Author

It looks like there are many noises to your last commit, related to code formating.

I don't think we apply such rules in the project lint configuration (we use eslint).

Hi,

I ran the eslint lint commands in package.json and checked for documentation regarding code formatting. These do not fix the prettier styles my local machine uses. Do you have any other tools I might be missing?

@fflorent
Copy link
Collaborator

I ran the eslint lint commands in package.json and checked for documentation regarding code formatting.

@Ajay-Satish-01 What are the commands you run for that?

Do you have any other tools I might be missing?

I think there's only eslint for the JS code.

@Ajay-Satish-01
Copy link
Author

I ran the eslint lint commands in package.json and checked for documentation regarding code formatting.

@Ajay-Satish-01 What are the commands you run for that?

Do you have any other tools I might be missing?

I think there's only eslint for the JS code.

Oh. Should I include TS then? Or will that be a separate issue?

@fflorent
Copy link
Collaborator

Should I include TS then? Or will that be a separate issue?

Sorry, I meant the TypeScript code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants