Skip to content

fix: Parse.Query.select('authData') for _User class doesn't return auth data#10055

Merged
mtrezza merged 4 commits intoparse-community:alphafrom
mtrezza:fix/auth-data-select
Feb 12, 2026
Merged

fix: Parse.Query.select('authData') for _User class doesn't return auth data#10055
mtrezza merged 4 commits intoparse-community:alphafrom
mtrezza:fix/auth-data-select

Conversation

@mtrezza
Copy link
Member

@mtrezza mtrezza commented Feb 12, 2026

Pull Request

Issue

Parse.Query.select('authData') for _User class doesn't return auth data. The reason is that the authData field is synthesized and actually stored as _auth_data_<PROVIDER> in the _User obj. So setting authData as selected key for MongoDB won't find a field of such name.

Summary by CodeRabbit

  • New Features

    • Retrieve a user’s authentication data when explicitly selected in queries using the master key.
    • Add a function to list configured authentication providers (built-in and custom).
  • Tests

    • Added a test verifying retrieval of authData via master-key queries.

@parse-github-assistant
Copy link

parse-github-assistant bot commented Feb 12, 2026

🚀 Thanks for opening this pull request!

@coderabbitai
Copy link

coderabbitai bot commented Feb 12, 2026

📝 Walkthrough

Walkthrough

Adds a test ensuring authData is returned when selected with masterKey, exposes a new getProviders() API to enumerate configured auth providers, and updates _User query projection to include internal _auth_data_<provider> fields when authData is requested.

Changes

Cohort / File(s) Summary
Test Coverage
spec/ParseUser.spec.js
Adds a test that logs in a user with Facebook auth, queries _User selecting authData with useMasterKey: true, and asserts returned authData contains facebook.id and facebook.access_token.
Auth Provider Discovery
src/Adapters/Auth/index.js
Adds and exports getProviders() which returns configured/auth-adapter-backed provider names (combines built-ins and custom providers; optionally excludes anonymous).
Query Projection Logic
src/RestQuery.js
When className is _User and authData is selected, appends internal _auth_data_<provider> keys for configured providers to the find projection so per-provider auth fields are returned from DBs that store them separately.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client
    participant REST as REST Layer (RestQuery)
    participant Auth as Auth Adapter Registry (getProviders)
    participant DB as Database

    Client->>REST: Request _User fields=authData (useMasterKey)
    REST->>Auth: getProviders()
    Auth-->>REST: ["facebook", ...]
    REST->>DB: find(query, projection: authData + _auth_data_facebook, ...)
    DB-->>REST: user record (includes _auth_data_facebook)
    REST-->>Client: user object with authData populated
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive The description identifies the issue but lacks implementation details and is missing critical sections from the template like Approach and Tasks checklist. Add an Approach section describing the implementation strategy and complete the Tasks checklist to indicate which tasks were completed for this PR.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main fix: enabling Parse.Query.select('authData') to return auth data for the _User class.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into alpha

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉


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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/Adapters/Auth/index.js`:
- Around line 264-270: The catch block in the filter over allProviders uses an
unused exception binding `e`; update the try/catch in the function that returns
[...allProviders].filter(...) (the block that calls loadAuthAdapter(provider,
authOptions)) to remove the unused binding by changing `catch (e)` to an empty
catch `catch {}` (and keep returning false inside it) so the linter no longer
complains about an unused variable while preserving the current behavior.
🧹 Nitpick comments (1)
src/Adapters/Auth/index.js (1)

257-271: Consider caching or memoizing the provider list.

getProviders() calls loadAuthAdapter() for every configured provider on each invocation. In RestQuery.runFind, this is called for every _User query that selects authData. Since the set of configured providers doesn't change at runtime (barring server reconfiguration), computing this repeatedly is wasteful. A simple lazy-cached value (invalidated on config change) would avoid redundant adapter loading.

@parseplatformorg
Copy link
Contributor

parseplatformorg commented Feb 12, 2026

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

Status Scanner Image Critical Image High Image Medium Image 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.

@codecov
Copy link

codecov bot commented Feb 12, 2026

Codecov Report

❌ Patch coverage is 92.85714% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.57%. Comparing base (1af6c0d) to head (48e5ead).
⚠️ Report is 2 commits behind head on alpha.

Files with missing lines Patch % Lines
src/Adapters/Auth/index.js 87.50% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            alpha   #10055   +/-   ##
=======================================
  Coverage   92.57%   92.57%           
=======================================
  Files         191      191           
  Lines       15589    15603   +14     
  Branches      176      176           
=======================================
+ Hits        14432    14445   +13     
- Misses       1145     1146    +1     
  Partials       12       12           

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

@mtrezza mtrezza merged commit 44a5bb1 into parse-community:alpha Feb 12, 2026
22 of 23 checks passed
@mtrezza mtrezza deleted the fix/auth-data-select branch February 12, 2026 20:46
parseplatformorg pushed a commit that referenced this pull request Feb 12, 2026
# [9.3.0-alpha.5](9.3.0-alpha.4...9.3.0-alpha.5) (2026-02-12)

### Bug Fixes

* `Parse.Query.select('authData')` for `_User` class doesn't return auth data ([#10055](#10055)) ([44a5bb1](44a5bb1))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 9.3.0-alpha.5

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

Labels

state:released-alpha Released as alpha version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants