Skip to content

fix: Server crashes on startup with cryptic error when a Mongo _SCHEMA field has a non-string type#10532

Open
dblythy wants to merge 1 commit into
parse-community:alphafrom
dblythy:fix/mongo-schema-non-string-type
Open

fix: Server crashes on startup with cryptic error when a Mongo _SCHEMA field has a non-string type#10532
dblythy wants to merge 1 commit into
parse-community:alphafrom
dblythy:fix/mongo-schema-non-string-type

Conversation

@dblythy

@dblythy dblythy commented Jul 4, 2026

Copy link
Copy Markdown
Member

Closes #9847

Summary by CodeRabbit

  • Bug Fixes
    • Improved schema conversion error handling when a field type is missing or invalid.
    • Error messages now clearly identify the affected class and field, making schema issues easier to diagnose.
    • Added coverage for these cases to ensure the expected Parse error is raised.

@parse-github-assistant

Copy link
Copy Markdown

🚀 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

  • Keep pull requests small. Large PRs will be rejected. Break complex features into smaller, incremental PRs.
  • Use Test Driven Development. Write failing tests before implementing functionality. Ensure tests pass.
  • Group code into logical blocks. Add a short comment before each block to explain its purpose.
  • We offer conceptual guidance. Coding is up to you. PRs must be merge-ready for human review.
  • Our review focuses on concept, not quality. PRs with code issues will be rejected. Use an AI agent.
  • Human review time is precious. Avoid review ping-pong. Inspect and test your AI-generated code.

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.

@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 72368639-4ea2-40e8-a87f-9cb8d3acd6ae

📥 Commits

Reviewing files that changed from the base of the PR and between 7e9d53a and 59ab0bb.

📒 Files selected for processing (2)
  • spec/MongoSchemaCollectionAdapter.spec.js
  • src/Adapters/Storage/Mongo/MongoSchemaCollection.js

📝 Walkthrough

Walkthrough

This change adds validation to mongoFieldToParseSchemaField in MongoSchemaCollection.js so that non-string field types throw a Parse.Error with INCORRECT_TYPE, including class and field name context, instead of crashing. Corresponding spec tests are added to verify this behavior.

Changes

Mongo Schema Field Type Validation

Layer / File(s) Summary
Type validation in schema field conversion
src/Adapters/Storage/Mongo/MongoSchemaCollection.js
mongoFieldToParseSchemaField now throws Parse.Error(INCORRECT_TYPE) with descriptive className/fieldName when type is not a string; caller now passes fieldName and schema._id into it.
Spec tests for invalid field types
spec/MongoSchemaCollectionAdapter.spec.js
Imports parse/node and adds test cases asserting _TESTmongoSchemaToParseSchema throws Parse.Error.INCORRECT_TYPE for null and non-string object field types.

Estimated code review effort: 2 (Simple) | ~10 minutes

Related Issues

  • #9847: TypeError: type.startsWith is not a function when starting Parse Server with custom schema data — resolved by adding type validation before calling startsWith.

Suggested Labels: bug, needs review

Suggested Reviewers: dblythy, mtrezza

🐰 A silent hop, a broken type, no more a crash upon the night; now Parse throws with words so clear, className and field draw near.

🚥 Pre-merge checks | ✅ 6 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is largely incomplete and only references the issue; it is missing the required Issue, Approach, and Tasks sections. Populate the template with an issue summary, implementation approach, and completed task checklist items.
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title uses the required fix: prefix and accurately summarizes the Mongo schema startup crash fix.
Linked Issues check ✅ Passed The change validates non-string _SCHEMA field types and prevents the startup crash described in #9847.
Out of Scope Changes check ✅ Passed The changes are limited to the reported Mongo schema fix and matching tests, with no unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Security Check ✅ Passed Only adds type validation and clearer Parse errors in schema parsing; no new injection, auth, or deserialization risk is introduced.
Engage In Review Feedback ✅ Passed No substantive review feedback was present—only automated @coderabbitai review requests/responses—so there was nothing to engage before merging.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

🔧 Biome (2.5.1)
src/Adapters/Storage/Mongo/MongoSchemaCollection.js

File contains syntax errors that prevent linting: Line 121: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 163: return types can only be used in TypeScript files; Line 165: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 173: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 186: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 190: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 204: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 208: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 208: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 223: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 223: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 223: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 291: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 291: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 291: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.


Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.66%. Comparing base (cce91e5) to head (59ab0bb).
⚠️ Report is 1 commits behind head on alpha.

Additional details and impacted files
@@           Coverage Diff           @@
##            alpha   #10532   +/-   ##
=======================================
  Coverage   92.66%   92.66%           
=======================================
  Files         193      193           
  Lines       16981    16983    +2     
  Branches      248      248           
=======================================
+ Hits        15736    15738    +2     
  Misses       1224     1224           
  Partials       21       21           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dblythy

dblythy commented Jul 5, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@dblythy

dblythy commented Jul 5, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.

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.

TypeError: type.startsWith is not a function when starting Parse Server with custom schema data

1 participant