fix: Preserve UTF-8 GraphQL upload filenames with latest graphql-upload#10478
fix: Preserve UTF-8 GraphQL upload filenames with latest graphql-upload#10478coratgerl wants to merge 4 commits into
Conversation
Load the latest ESM-only graphql-upload through a small compatibility layer so GraphQL uploads keep accented filenames intact without changing Parse Server's public module model. Co-authored-by: Cursor <cursoragent@cursor.com>
|
I will reformat the title to use the proper commit message syntax. |
|
🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review. Tip
Note Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect. Caution Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (15)
📝 WalkthroughWalkthroughUpgrades graphql-upload to v17 with an ESM-aware dynamic-import adapter, defers GraphQL upload type initialization to schema load, URL-encodes proxied file paths, adds Unicode filename normalization across adapters/controllers/routers, and adds tests for accented filenames. ChangesGraphQL Upload ESM Migration and Unicode Support
Sequence Diagram(s)sequenceDiagram
participant Client
participant ParseGraphQLServer
participant createGraphQLUploadMiddleware
participant getGraphQLUpload
participant graphql_upload_ESM
Client->>ParseGraphQLServer: POST multipart/form-data (café.txt)
ParseGraphQLServer->>createGraphQLUploadMiddleware: invoke middleware(req, res, next)
createGraphQLUploadMiddleware->>getGraphQLUpload: ensure dynamic modules loaded (cached)
getGraphQLUpload->>graphql_upload_ESM: dynamic import (GraphQLUpload, processRequest)
createGraphQLUploadMiddleware->>graphql_upload_ESM: processRequest(req, defParamCharset: 'utf8')
graphql_upload_ESM-->>createGraphQLUploadMiddleware: populate req.body with file fields (filename decoded to café.txt)
createGraphQLUploadMiddleware->>ParseGraphQLServer: next()
ParseGraphQLServer->>FilesController: validateFilename(normalizeFilename(_café.txt))
ParseGraphQLServer->>FilesController: createFile -> adapter.createFile(normalized filename)
FilesController->>GridFSBucketAdapter: createFile(normalized filename)
GridFSBucketAdapter-->>FilesController: response (stored name, url with encoded path caf%C3%A9.txt)
ParseGraphQLServer-->>Client: GraphQL response with name and encoded URL
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 5 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 OpenGrep (1.22.0)OpenGrep fatal error (exit code 2): [00.18][ERROR]: Error: exception Unix_error: No such file or directory stat package.json 🔧 Checkov (3.2.529)package.json2026-05-26 08:12:50,857 [MainThread ] [ERROR] Template file not found: package.json ... [truncated 2548 characters] ... k__) 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/GraphQL/loaders/filesMutations.js`:
- Around line 41-53: The response handling treats 3xx as success and uses a
nonexistent Parse.error constant in the catch; change the status check to reject
for any non-2xx (use if (res.statusCode < 200 || res.statusCode >= 300)) and
update the catch to capture the thrown error and reject with a real Parse.Error
code constant (e.g., use Parse.Error.FILE_SAVE_ERROR or another appropriate
Parse.Error.* code) so the reject call uses new
Parse.Error(Parse.Error.FILE_SAVE_ERROR, errorOrData) and includes the caught
error details; locate these changes around the parsedData/res.statusCode
handling and the catch that currently calls reject(new Parse.Error(Parse.error,
data)).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a99d2150-8ad0-460f-ac62-c9b90904bbd1
📒 Files selected for processing (9)
package-lock.jsonpackage.jsonspec/ParseGraphQLServer.spec.jssrc/Adapters/Files/FilesAdapter.jssrc/GraphQL/ParseGraphQLSchema.jssrc/GraphQL/ParseGraphQLServer.jssrc/GraphQL/helpers/graphqlUpload.jssrc/GraphQL/loaders/defaultGraphQLTypes.jssrc/GraphQL/loaders/filesMutations.js
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## alpha #10478 +/- ##
=======================================
Coverage 92.57% 92.58%
=======================================
Files 193 194 +1
Lines 16884 16932 +48
Branches 234 234
=======================================
+ Hits 15631 15676 +45
- Misses 1230 1233 +3
Partials 23 23 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Reject non-2xx responses from the internal /files handoff and use Parse.Error.FILE_SAVE_ERROR when the response body is not valid JSON. Add regression tests for accented filenames in FilesController and Parse.File. Co-authored-by: Cursor <cursoragent@cursor.com>
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/Adapters/Files/FilesAdapter.js`:
- Line 115: Filename normalization is missing: validateFilename only tests the
regex but never normalizes, causing NFC/NFD mismatches across storage and
lookups. Normalize filenames (and each path segment) to a consistent Unicode
form (e.g., NFC) at the point the storage key is finalized and always pass that
normalized value into GridFS operations; update FilesAdapter (add or change
validateFilename to return/produce a normalized filename or add a new
normalizeFilename helper), ensure FilesRouter/FilesController call that
normalizer before upload/download/delete/metadata, and make GridFSBucketAdapter
use the normalized name for openUploadStream(filename),
openDownloadStreamByName, bucket.find({ filename }), delete, and any other
filename lookups.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: bfd78a56-4652-4ed2-b00c-ac8ba20f9045
📒 Files selected for processing (11)
package-lock.jsonpackage.jsonspec/FilesController.spec.jsspec/ParseFile.spec.jsspec/ParseGraphQLServer.spec.jssrc/Adapters/Files/FilesAdapter.jssrc/GraphQL/ParseGraphQLSchema.jssrc/GraphQL/ParseGraphQLServer.jssrc/GraphQL/helpers/graphqlUpload.jssrc/GraphQL/loaders/defaultGraphQLTypes.jssrc/GraphQL/loaders/filesMutations.js
Normalize file names to NFC before finalizing storage keys so uploads, reads, metadata lookups, and deletes resolve the same GridFS record across Unicode forms. Co-authored-by: Cursor <cursoragent@cursor.com>
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
Summary
graphql-uploadto the latest ESM-only release while keeping Parse Server on its current public module model via a small private compatibility helper/fileshandoff safely, and allowing accented characters through filename validationcafé.txtuploads and keep existing GraphQL upload coverage greenThis PR was done in TDD.
Test plan
spec/ParseGraphQLServer.spec.jsspec/ParseFile.spec.jsfilename checksnpm run lintnpm testNotes
npm testfinishes with one unrelated pre-existing failure inParse.Query testing order by _updated_atMade with Cursor
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Chores