Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply increased json body limit to entity post endpoint #1123

Merged
merged 2 commits into from
Apr 14, 2024

Conversation

ktuite
Copy link
Member

@ktuite ktuite commented Apr 11, 2024

Part of #1095

Adds custom middleware to use a higher JSON size limit for bodyParser middleware for the specific entity bulk creation route.

Uses path-to-regex to match the route, because I think that is what express is using internally, so this dependency should technically already be included.

What has been done to verify that this works as intended?

Why is this the best possible solution? Were any other approaches considered?

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

Does this change require updates to the API documentation? If so, please update docs/api.md as part of this PR.

Before submitting this PR, please make sure you have:

  • run make test and confirmed all checks still pass OR confirm CircleCI build passes
  • verified that any code from external sources are properly credited in comments or that everything is internally sourced


// use a default json limit except for URLs that explicitly need a larger limit.
const defaultJsonLimit = bodyParser.json({ type: 'application/json', limit: '250kb' });
const largeJsonLimit = bodyParser.json({ type: 'application/json', limit: '100mb' });
Copy link
Member

Choose a reason for hiding this comment

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

I think it's reasonable to hard-code 100mb here for now. Once we take a look at getodk/central#609, we should look into ways to keep this limit consistent across nginx, Backend, and Frontend (e.g., via an environment variable).

lib/http/service.js Show resolved Hide resolved
lib/http/service.js Outdated Show resolved Hide resolved
lib/http/service.js Outdated Show resolved Hide resolved
@ktuite ktuite merged commit 59e2165 into master Apr 14, 2024
5 checks passed
@ktuite ktuite deleted the ktuite/json_limit branch April 14, 2024 20:56
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