Skip to content

fix: User cannot retrieve own email with protectedFieldsOwnerExempt: false despite email not in protectedFields#10284

Merged
mtrezza merged 3 commits intoparse-community:alphafrom
mtrezza:test/protectedFields-user
Mar 22, 2026
Merged

fix: User cannot retrieve own email with protectedFieldsOwnerExempt: false despite email not in protectedFields#10284
mtrezza merged 3 commits intoparse-community:alphafrom
mtrezza:test/protectedFields-user

Conversation

@mtrezza
Copy link
Member

@mtrezza mtrezza commented Mar 22, 2026

Pull Request

Issue

When protectedFieldsOwnerExempt is set to false, Parse Server still merges the default protectedFields (e.g. email) into any custom protectedFields configuration for the _User class. This means that even if a developer explicitly configures protectedFields: { _User: { '*': ['phone'] } } without including email, the email field is silently added to the protected fields list. As a result, the user cannot retrieve their own email address, despite email not being in the developer's protectedFields configuration.

Fix

When protectedFieldsOwnerExempt is false and the developer has explicitly configured a class+role combination in protectedFields (e.g. _User['*']), the default protected fields for that combination are no longer merged in. Only the explicitly configured fields apply. When protectedFieldsOwnerExempt is true (default), the existing merge behavior is preserved for backward compatibility.

Example

{
  protectedFields: { _User: { '*': ['phone'] } },
  protectedFieldsOwnerExempt: false
}

Before fix: email is silently added → user cannot see their own email.
After fix: only phone is protected → user can see their own email but not phone.

Tasks

  • Add tests
  • Add changes to documentation (guides, repository pages, code comments)
  • Add security check
  • Add new Parse Error codes to Parse JS SDK

Summary by CodeRabbit

  • Tests

    • Added coverage for the protectedFieldsOwnerExempt behavior, confirming owners see protected user fields when enabled and are restricted when disabled.
  • Documentation

    • Clarified the protectedFieldsOwnerExempt option descriptions to explain how default protected fields are merged or not when owners query their own user object.
  • Chores

    • Adjusted protected-fields merging logic to respect the owner-exempt configuration.

@parse-github-assistant
Copy link

parse-github-assistant bot commented Mar 22, 2026

🚀 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.

@parseplatformorg
Copy link
Contributor

parseplatformorg commented Mar 22, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@coderabbitai
Copy link

coderabbitai bot commented Mar 22, 2026

📝 Walkthrough

Walkthrough

Added tests for owner-exempt protected-field behavior and changed server initialization to conditionally merge default protected fields based on the protectedFieldsOwnerExempt flag.

Changes

Cohort / File(s) Summary
Tests
spec/ProtectedFields.spec.js
Added two test cases under protectedFieldsOwnerExempt that assert owner-visible protected fields (phone) are present when the flag is true and absent when false.
Server initialization
src/ParseServer.ts
Adjusted injectDefaults logic to skip merging default protectedFields into existing options.protectedFields[c][r] when protectedFieldsOwnerExempt === false; otherwise union and deduplicate default values.
Options docs & help text
src/Options/...
src/Options/Definitions.js, src/Options/docs.js, src/Options/index.js
Clarified protectedFieldsOwnerExempt documentation/help to state that when true defaults (e.g., email) are merged into custom protectedFields, and when false defaults are not merged and only explicit configs apply.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The description includes a clear problem statement, the fix approach with examples, and completion of required checklist items (tests and documentation added).
Title check ✅ Passed The title accurately describes the core fix: addressing how default protectedFields override custom configuration when protectedFieldsOwnerExempt is false, enabling users to retrieve their own email field.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

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

@mtrezza mtrezza changed the title fix: Default protectedFields override custom config when protectedFieldsOwnerExempt: false fix: User cannot retrieve own email when protectedFieldsOwnerExempt is false and email not in protectedFields Mar 22, 2026
@mtrezza mtrezza changed the title fix: User cannot retrieve own email when protectedFieldsOwnerExempt is false and email not in protectedFields fix: User cannot retrieve own email with protectedFieldsOwnerExempt: false despite email not in protectedFields Mar 22, 2026
@mtrezza mtrezza merged commit 4a65d77 into parse-community:alpha Mar 22, 2026
20 of 22 checks passed
parseplatformorg pushed a commit that referenced this pull request Mar 22, 2026
## [9.6.1-alpha.1](9.6.0...9.6.1-alpha.1) (2026-03-22)

### Bug Fixes

* User cannot retrieve own email with `protectedFieldsOwnerExempt: false` despite `email` not in `protectedFields` ([#10284](#10284)) ([4a65d77](4a65d77))
@mtrezza mtrezza deleted the test/protectedFields-user branch March 22, 2026 20:28
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 9.6.1-alpha.1

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Mar 22, 2026
@codecov
Copy link

codecov bot commented Mar 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.55%. Comparing base (cc04fb1) to head (95292b1).
⚠️ Report is 8 commits behind head on alpha.

Additional details and impacted files
@@            Coverage Diff             @@
##            alpha   #10284      +/-   ##
==========================================
+ Coverage   92.53%   92.55%   +0.01%     
==========================================
  Files         192      192              
  Lines       16482    16484       +2     
  Branches      226      227       +1     
==========================================
+ Hits        15252    15256       +4     
+ Misses       1210     1208       -2     
  Partials       20       20              

☔ View full report in Codecov by Sentry.
📢 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.

parseplatformorg pushed a commit that referenced this pull request Mar 22, 2026
## [9.6.1](9.6.0...9.6.1) (2026-03-22)

### Bug Fixes

* User cannot retrieve own email with `protectedFieldsOwnerExempt: false` despite `email` not in `protectedFields` ([#10284](#10284)) ([4a65d77](4a65d77))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 9.6.1

@parseplatformorg parseplatformorg added the state:released Released as stable version label Mar 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state:released Released as stable version state:released-alpha Released as alpha version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants