Skip to content

fix(core): evaluate nested exists false filter when parent key is nullish (#5017) - #5023

Closed
GauravPatil2515 wants to merge 1 commit into
triggerdotdev:mainfrom
GauravPatil2515:fix/issue-5017-event-filter-exists-false
Closed

GauravPatil2515 wants to merge 1 commit into
triggerdotdev:mainfrom
GauravPatil2515:fix/issue-5017-event-filter-exists-false

Conversation

@GauravPatil2515

Copy link
Copy Markdown

Description

Resolves #5017.

In packages/core/src/eventFilterMatches.ts, an early-return check previously evaluated payload === undefined || payload === null by immediately returning false for any non-empty filter. Consequently, nested negative checks such as { user: { email: [{ $exists: false }] } } evaluated to false when user was absent or null in the payload, even though user.email correctly does not exist in that case.

This PR replaces the early bailout with const safePayload = payload ?? {}, allowing nested filter evaluation to naturally traverse nullish ancestor objects and correctly resolve $exists: false.

Changes Made

  • Updated eventFilterMatches in packages/core/src/eventFilterMatches.ts to evaluate keys against a fallback safe payload rather than discarding valid $exists: false leaves.
  • Added unit tests in packages/core/test/eventFilterMatches.test.ts covering nested $exists: false when parent keys are missing or null.

Checklist

  • Tested locally with missing, null, and populated parent payloads
  • Includes unit test coverage
  • Signed off commit with DCO

…lish (triggerdotdev#5017)

Signed-off-by: Gaurav Patil <gauravpatil2516@gmail.com>
@changeset-bot

changeset-bot Bot commented Oct 12, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: f953770

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 769e9f14-35bd-4a72-84e8-e32fe3fa1062

📥 Commits

Reviewing files that changed from the base of the PR and between 598fdf2 and f953770.


📒 Files selected for processing (2)
  • packages/core/src/eventFilterMatches.ts
  • packages/core/test/eventFilterMatches.test.ts

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

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@github-actions

Copy link
Copy Markdown
Contributor

Hi @GauravPatil2515, thanks for your interest in contributing!

This project requires that pull request authors are vouched, and you are not in the list of vouched users.

This PR will be closed automatically. See https://github.com/triggerdotdev/trigger.dev/blob/main/CONTRIBUTING.md for more details.

@github-actions github-actions Bot closed this Oct 12, 2026

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 2 potential issues.

Devin Review

Comment on lines +8 to +11
const safePayload = payload ?? {};

for (const [patternKey, patternValue] of Object.entries(filter)) {
const payloadValue = payload[patternKey];
const payloadValue = safePayload[patternKey];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Missing nested keys appear to exist

For a nullish parent, safePayload makes $exists: false fail on keys like constructor. The fallback {} inherits those keys, so a missing child appears present.

Learn more

The matcher treats nullish payloads as an empty object so nested filters can evaluate missing children. Ordinary {} inherits keys such as constructor, toString, and __proto__. Reading one of those keys returns an inherited value rather than undefined, which makes $exists: false reject an absent child. The same lookup also affects a parent supplied as {}, but that case predates this change.

Example: With payload { user: null } and filter { user: { constructor: [{ $exists: false }] } }, the matcher returns false. No constructor child exists, so this filter must match.

Recommended fix: Resolve payloadValue using an own-property check before indexing safePayload, returning undefined for inherited keys. Cover nullish parents and ordinary empty objects with a regression test.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

return false;
}
}
const safePayload = payload ?? {};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔍 User-facing filter fix lacks a changeset

This changes published filter behavior, but the PR has no changeset. Repository guidance calls for one for user-facing package fixes.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

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.

Bug: eventFilterMatches returns false for nested $exists: false when the parent key is missing or null

1 participant