Skip to content

Fix Storage Emulator JSON upload limit and body parsing hangs#10800

Merged
joehan merged 7 commits into
mainfrom
fix-storage-json-limit
Jul 17, 2026
Merged

Fix Storage Emulator JSON upload limit and body parsing hangs#10800
joehan merged 7 commits into
mainfrom
fix-storage-json-limit

Conversation

@joehan

@joehan joehan commented Jul 15, 2026

Copy link
Copy Markdown
Member

Addresses issue #8355. Fixes the Storage Emulator to handle large JSON uploads without throwing 413 or hanging due to eager body parsing.

@wiz-9635d3485b

wiz-9635d3485b Bot commented Jul 15, 2026

Copy link
Copy Markdown

Wiz Scan Summary

Scanner Findings
Vulnerability Finding Vulnerabilities -
Data Finding Sensitive Data -
Secret Finding Secrets -
IaC Misconfiguration IaC Misconfigurations -
SAST Finding SAST Findings 2 Medium 3 Low
Software Management Finding Software Management Findings -
Total 2 Medium 3 Low

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request increases the request body size limit to 130MB for various storage emulator endpoints (both Firebase and GCloud APIs) to handle large uploads and JSON payloads, addressing issue #8355. It introduces custom upload middlewares to conditionally apply the larger limits and removes the global JSON parser in favor of route-specific parsers. Feedback suggests removing a redundant ?.toString() call on req.header() since Express already returns a string or undefined.

Comment thread src/emulator/storage/apis/firebase.ts Outdated
return json({ limit: "130mb" })(req, res, next);
}

const uploadType = req.header("x-goog-upload-protocol")?.toString();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The req.header() method in Express already returns a string or undefined. Calling ?.toString() on it is redundant and can be safely removed.

Suggested change
const uploadType = req.header("x-goog-upload-protocol")?.toString();
const uploadType = req.header("x-goog-upload-protocol");

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed - this is uneceesary

Comment thread src/emulator/storage/apis/gcloud.ts Outdated
@joehan
joehan marked this pull request as ready for review July 15, 2026 21:53
Comment thread src/emulator/storage/apis/gcloud.ts Outdated
import { reqBodyToBuffer } from "../../shared/request";
import type { Query } from "express-serve-static-core";

/**

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Remove this

@joehan
joehan requested a review from aalej July 15, 2026 22:04

@aalej aalej left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

tested against https://github.com/aalej/issues-8355 - works
tested file uploads via console(emulator ui) - works

  • images
  • files with special chars on name
  • json files
  • multiple file upload

tested curl uploads - works

expect(String(data)).to.eql("hello world");
});

it("should handle large JSON uploads (issue #8355)", async () => {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No need to mention the issue number here.

@joehan
joehan enabled auto-merge (squash) July 16, 2026 22:23
@joehan
joehan merged commit 96ad6ba into main Jul 17, 2026
53 checks passed
@joehan
joehan deleted the fix-storage-json-limit branch July 17, 2026 22:14
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.

3 participants