Title: Bug: eventFilterMatches returns false for nested $exists: false when the parent key is missing or null · Issue #5017 · triggerdotdev/trigger.dev · GitHub
Open Graph Title: Bug: eventFilterMatches returns false for nested $exists: false when the parent key is missing or null · Issue #5017 · triggerdotdev/trigger.dev
X Title: Bug: eventFilterMatches returns false for nested $exists: false when the parent key is missing or null · Issue #5017 · triggerdotdev/trigger.dev
Description: Summary eventFilterMatches returns false for a nested $exists: false filter when the parent key is missing or null in the payload. The function returns false for any non-empty filter as soon as it meets an undefined/null payload, before ...
Open Graph Description: Summary eventFilterMatches returns false for a nested $exists: false filter when the parent key is missing or null in the payload. The function returns false for any non-empty filter as soon as it ...
X Description: Summary eventFilterMatches returns false for a nested $exists: false filter when the parent key is missing or null in the payload. The function returns false for any non-empty filter as soon as it ...
Opengraph URL: https://github.com/triggerdotdev/trigger.dev/issues/5017
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Bug: eventFilterMatches returns false for nested $exists: false when the parent key is missing or null","articleBody":"## Summary\n`eventFilterMatches` returns `false` for a nested `$exists: false` filter when the parent key is missing or `null` in the payload. The function returns `false` for any non-empty filter as soon as it meets an `undefined`/`null` payload, before it evaluates `$exists`. This is user-facing through `retry.fetch`'s `bodyFilter`, which calls `eventFilterMatches` on the response body.\n\n## Reproduction\n1. Setup: `packages/core` on `main`.\n2. Command: `npx tsx repro.ts` from `packages/core` with:\n```ts\nimport { eventFilterMatches } from \"./src/eventFilterMatches.js\";\nconst f = { user: { email: [{ $exists: false }] } };\nconsole.log(eventFilterMatches({}, f)); // false\nconsole.log(eventFilterMatches({ user: null }, f)); // false\nconsole.log(eventFilterMatches({ user: {} }, f)); // true\nconsole.log(eventFilterMatches({}, { email: [{ $exists: false }] })); // true\n```\n3. Trigger: a nested filter whose leaf is `$exists: false`, used with a payload where an ancestor key is absent or `null`.\n\n## Actual behavior\n```\n{} {\"user\":{\"email\":[{\"$exists\":false}]}} => false\n{\"user\":null} {\"user\":{\"email\":[{\"$exists\":false}]}} => false\n{\"user\":{}} {\"user\":{\"email\":[{\"$exists\":false}]}} => true\n{} {\"email\":[{\"$exists\":false}]} => true\n```\n\n## Expected behavior\nAll four should return `true`. If `user` is missing, then `user.email` doesn't exist either, which is exactly what `$exists: false` asserts. Top-level `$exists: false` already behaves that way (case 4, and the existing test \"should return true when payload does NOT have a key that $exists = false\"). Nesting the same condition one level deeper shouldn't flip the result.\n\n## Environment\n- Version/commit: `main` @ 93465d8549a735074d1ce7696bae3faebe577e8d\n- OS: Ubuntu (Linux), Node v24.21.0\n- Relevant configuration: none; pure function. Reachable from `retry.fetch(url, { retry: { byStatus: { \"...\": { strategy: \"backoff\", bodyFilter } } } })`\n\n## Evidence\n- Early return for `undefined`/`null` payload with a non-empty filter: https://github.com/triggerdotdev/trigger.dev/blob/93465d8549a735074d1ce7696bae3faebe577e8d/packages/core/src/eventFilterMatches.ts#L7-L14\n- Recursion into nested object filters: https://github.com/triggerdotdev/trigger.dev/blob/93465d8549a735074d1ce7696bae3faebe577e8d/packages/core/src/eventFilterMatches.ts#L61-L71\n- `retry.fetch` `bodyFilter` path: https://github.com/triggerdotdev/trigger.dev/blob/93465d8549a735074d1ce7696bae3faebe577e8d/packages/trigger-sdk/src/v3/retry.ts#L449-L460\n- `bodyFilter: EventFilter` in the fetch retry schema: https://github.com/triggerdotdev/trigger.dev/blob/93465d8549a735074d1ce7696bae3faebe577e8d/packages/core/src/v3/schemas/fetch.ts#L17 and https://github.com/triggerdotdev/trigger.dev/blob/93465d8549a735074d1ce7696bae3faebe577e8d/packages/core/src/v3/schemas/fetch.ts#L39\n- Existing tests cover only top-level `$exists`: https://github.com/triggerdotdev/trigger.dev/blob/93465d8549a735074d1ce7696bae3faebe577e8d/packages/core/test/eventFilterMatches.test.ts#L193-L208\n\n## Additional context\n**Confirmed:** the four results above, from running the source on `main`.\n\n**Inference:** for `retry.fetch`, a `bodyFilter` such as `{ error: { retryAfter: [{ $exists: false }] } }` won't match a body that has no `error` object at all. That strategy is then skipped. I haven't exercised this through `retry.fetch` end to end.\n\n**Possible fix:** when the payload is `undefined`/`null`, evaluate the filter against an empty object (or recurse with `{}`) instead of returning `false`, so that `$exists: false` and `$isNull`-style leaves still get evaluated.\n\nFound with an [anti-slop](https://github.com/dmmulroy/anti-slop) oxlint scan (`no-runtime-typeof`), then checked by hand.\n","author":{"url":"https://github.com/apps/devin-ai-integration","@type":"Person","name":"devin-ai-integration"},"datePublished":"2026-10-11T19:15:47Z","url":"https://github.com/triggerdotdev/trigger.dev/issues/5017"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2e2045fb-5685-adf7-4988-2547e9e03215 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A5F2:3F7AD1:6A6164:98DB3B:6AFAD858 |
| html-safe-nonce | 5948cf10351f112258449ca04a5de811a632573f864ad756f09d87798aad9bd0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNUYyOjNGN0FEMTo2QTYxNjQ6OThEQjNCOjZBRkFEODU4IiwidmlzaXRvcl9pZCI6Ijg3MzYzMTMzODg1NDk0NjIxMDQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 0465e09ed9124e9aed7d025f856748d177b28c25a94e48fa7ce73e975163162b |
| hovercard-subject-tag | issue:5804294461 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/triggerdotdev/trigger.dev/5017/issue_layout |
| twitter:image | https://opengraph.githubassets.com/78293f60f710b3ddcc7f408ba03f8003b769f030cb6c942911a5c5028d0c3049/triggerdotdev/trigger.dev/issues/5017 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/78293f60f710b3ddcc7f408ba03f8003b769f030cb6c942911a5c5028d0c3049/triggerdotdev/trigger.dev/issues/5017 |
| og:image:alt | Summary eventFilterMatches returns false for a nested $exists: false filter when the parent key is missing or null in the payload. The function returns false for any non-empty filter as soon as it ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | devin-ai-integration[bot] |
| hostname | github.com |
| expected-hostname | github.com |
| None | 02f4c00e74911c7cd779fc232c3130cee49eb39fd0ed4bfe3eea3b82c7c18084 |
| turbo-cache-control | no-preview |
| go-import | github.com/triggerdotdev/trigger.dev git https://github.com/triggerdotdev/trigger.dev.git |
| octolytics-dimension-user_id | 95297378 |
| octolytics-dimension-user_login | triggerdotdev |
| octolytics-dimension-repository_id | 572570113 |
| octolytics-dimension-repository_nwo | triggerdotdev/trigger.dev |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 572570113 |
| octolytics-dimension-repository_network_root_nwo | triggerdotdev/trigger.dev |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 33c41e9d150e44415272934d676dc63c57d89c3b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width