Skip to content

fix: Crash when filtering unique on a pointer field#3386

Open
dblythy wants to merge 1 commit into
parse-community:alphafrom
dblythy:fix/2657-unique-pointer-crash
Open

fix: Crash when filtering unique on a pointer field#3386
dblythy wants to merge 1 commit into
parse-community:alphafrom
dblythy:fix/2657-unique-pointer-crash

Conversation

@dblythy

@dblythy dblythy commented Jul 4, 2026

Copy link
Copy Markdown
Member

Closes #2657

Before and after

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of pointer-based values so browser cells no longer rely on missing data access methods.
    • Fixed unique-row rendering for user records so required-field logic is only applied when appropriate.
    • Added coverage to help ensure unique filters render safely for user pointers without errors.

@parse-github-assistant

Copy link
Copy Markdown

I will reformat the title to use the proper commit message syntax.

@parse-github-assistant parse-github-assistant Bot changed the title fix: crash when filtering unique on a pointer field fix: Crash when filtering unique on a pointer field Jul 4, 2026
@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

📝 Walkthrough

Walkthrough

This PR fixes a crash when applying the unique filter on a Pointer field. BrowserCell now guards pointer value extraction by checking that value.get is a function, and BrowserRow only computes _User-specific required columns when isUnique is false. A regression test is added.

Changes

Unique filter pointer crash fix

Layer / File(s) Summary
Guard pointer value extraction and required-column logic
src/components/BrowserCell/BrowserCell.react.js, src/components/BrowserRow/BrowserRow.react.js
BrowserCell checks that value.get is a function before using it to extract defaultPointerKey; BrowserRow only computes _User required-fields mapping when isUnique is false.
Regression test for unique filter on Pointer
src/lib/tests/BrowserRow.test.js
Adds a test suite mocking localStorage and rendering BrowserRow with isUnique={true} and a raw Pointer to _User, verifying no crash occurs.

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

Sequence Diagram(s)

sequenceDiagram
  participant BrowserRow
  participant BrowserCell

  BrowserRow->>BrowserRow: check isUnique flag
  alt isUnique is true
    BrowserRow->>BrowserRow: skip _User requiredCols mapping
  else isUnique is false
    BrowserRow->>BrowserRow: compute _User requiredCols
  end
  BrowserRow->>BrowserCell: renderCellContent(value)
  BrowserCell->>BrowserCell: check value.get is function
  alt value.get exists
    BrowserCell->>BrowserCell: extract defaultPointerKey via get
  else value.get missing
    BrowserCell->>BrowserCell: skip get call, avoid crash
  end
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 6 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is missing the required Issue, Approach, and Tasks sections from the template. Add the Issue, Approach, and Tasks sections, and briefly explain the fix plus whether tests and docs were added.
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title uses the required fix: prefix and clearly describes the pointer-field unique filter crash.
Linked Issues check ✅ Passed The code changes address the reported unique-filter crash on pointer fields and add coverage for the fix.
Out of Scope Changes check ✅ Passed The changes shown are scoped to the pointer unique-filter crash fix and its test coverage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Security Check ✅ Passed Only adds guards around pointer access and skips _User required-field mapping for unique rows; no new dangerous sinks or auth/data-flow changes.
Engage In Review Feedback ✅ Passed No actionable review feedback comments existed; only an automated review trigger acknowledgment was recorded.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@dblythy

dblythy commented Jul 6, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/components/BrowserCell/BrowserCell.react.js (2)

96-113: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

copyableValue still reads the raw prop instead of the converted value.

Line 96-100 builds a proper Parse.Object (with .id set from objectId) into the local value variable specifically to handle raw Pointer objects, but line 113 assigns this.copyableValue = this.props.value.id — the original prop, which has no .id for raw pointers. Now that the crash on line 74 is fixed, this path is reachable and will silently set copyableValue to undefined for unique-filtered Pointer cells, breaking copy/"Add to config" functionality for exactly the scenario this PR fixes.

🐛 Proposed fix
-      this.copyableValue = this.props.value.id;
+      this.copyableValue = value.id;
🤖 Prompt for 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.

In `@src/components/BrowserCell/BrowserCell.react.js` around lines 96 - 113, The
BrowserCell.react.js pointer handling still sets copyableValue from the raw
props instead of the normalized local value, so raw Pointer objects end up with
undefined copy data. Update the BrowserCell render path that builds the
Parse.Object and passes it into the Pill onClick handler so that copyableValue
is assigned from the converted value (the local value with id populated from
objectId) rather than this.props.value. This should be fixed in the same
BrowserCell logic that handles the __type Pointer branch and the copyableValue
assignment.

620-655: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Guard raw Pointer values before toPointer() in pickFilter src/components/BrowserCell/BrowserCell.react.js:620-628 — unique-mode Pointer cells pass raw JSON through here, so comparable filter actions from the context menu can throw TypeError: value.toPointer is not a function. A fallback for plain pointer JSON would keep filtering working.

🤖 Prompt for 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.

In `@src/components/BrowserCell/BrowserCell.react.js` around lines 620 - 655, The
Pointer branch in pickFilter assumes value always has toPointer(), but
unique-mode Pointer cells can pass raw JSON and crash comparable filter actions.
Update pickFilter in BrowserCell.react.js to detect plain Pointer objects before
calling toPointer(), and fall back to using the raw pointer-shaped value when no
method exists. Keep the fix localized to the Pointer case inside pickFilter so
context-menu filtering still builds the compareTo value safely.
🧹 Nitpick comments (2)
src/lib/tests/BrowserRow.test.js (2)

109-115: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

global.localStorage mock isn't restored after the suite.

Setting global.localStorage in beforeAll without an afterAll cleanup leaves the mock in place for any subsequent code executed in the same test file/process, which could mask real localStorage-dependent behavior in other tests.

🤖 Prompt for 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.

In `@src/lib/tests/BrowserRow.test.js` around lines 109 - 115, The test setup in
BrowserRow.test.js leaves the global.localStorage mock in place after the suite,
which can affect later tests in the same process. Update the existing beforeAll
setup by adding matching afterAll cleanup that restores the original
global.localStorage value, and keep the mock scoped to the BrowserRow test suite
so subsequent tests see the real storage behavior.

108-131: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider asserting rendered content, not just "no throw".

The test only checks that rendering doesn't throw. Strengthening it to also assert the rendered pointer value (e.g. user1 objectId showing up in the tree) would better match the PR's stated goal ("distinct pointer values render") and guard against silent regressions where rendering succeeds but shows wrong/blank content.

🤖 Prompt for 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.

In `@src/lib/tests/BrowserRow.test.js` around lines 108 - 131, The Unique filter
test only verifies that BrowserRow renders without throwing, so it should also
assert the rendered pointer content. Update the BrowserRow.test.js case around
BrowserRow/renderer.create to inspect the rendered tree and confirm the unique
_User pointer objectId (such as user1) is visible in the output, not just that
rendering succeeds. Keep the existing no-throw check if helpful, but add a
concrete content assertion so the test covers the intended distinct pointer
rendering behavior.
🤖 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.

Outside diff comments:
In `@src/components/BrowserCell/BrowserCell.react.js`:
- Around line 96-113: The BrowserCell.react.js pointer handling still sets
copyableValue from the raw props instead of the normalized local value, so raw
Pointer objects end up with undefined copy data. Update the BrowserCell render
path that builds the Parse.Object and passes it into the Pill onClick handler so
that copyableValue is assigned from the converted value (the local value with id
populated from objectId) rather than this.props.value. This should be fixed in
the same BrowserCell logic that handles the __type Pointer branch and the
copyableValue assignment.
- Around line 620-655: The Pointer branch in pickFilter assumes value always has
toPointer(), but unique-mode Pointer cells can pass raw JSON and crash
comparable filter actions. Update pickFilter in BrowserCell.react.js to detect
plain Pointer objects before calling toPointer(), and fall back to using the raw
pointer-shaped value when no method exists. Keep the fix localized to the
Pointer case inside pickFilter so context-menu filtering still builds the
compareTo value safely.

---

Nitpick comments:
In `@src/lib/tests/BrowserRow.test.js`:
- Around line 109-115: The test setup in BrowserRow.test.js leaves the
global.localStorage mock in place after the suite, which can affect later tests
in the same process. Update the existing beforeAll setup by adding matching
afterAll cleanup that restores the original global.localStorage value, and keep
the mock scoped to the BrowserRow test suite so subsequent tests see the real
storage behavior.
- Around line 108-131: The Unique filter test only verifies that BrowserRow
renders without throwing, so it should also assert the rendered pointer content.
Update the BrowserRow.test.js case around BrowserRow/renderer.create to inspect
the rendered tree and confirm the unique _User pointer objectId (such as user1)
is visible in the output, not just that rendering succeeds. Keep the existing
no-throw check if helpful, but add a concrete content assertion so the test
covers the intended distinct pointer rendering behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6669f191-7d22-499f-af3c-860eee9b9629

📥 Commits

Reviewing files that changed from the base of the PR and between 9db24be and 0c989f7.

📒 Files selected for processing (3)
  • src/components/BrowserCell/BrowserCell.react.js
  • src/components/BrowserRow/BrowserRow.react.js
  • src/lib/tests/BrowserRow.test.js

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.

Crash on filter unique for pointer

1 participant