Skip to content

Keep events when core plugins or serialization hit bad data - #219

Draft
ejsmith wants to merge 2 commits into
mainfrom
fix/core-event-data-safety
Draft

ejsmith wants to merge 2 commits into
mainfrom
fix/core-event-data-safety

Conversation

@ejsmith

@ejsmith ejsmith commented Dec 2, 2026

Copy link
Copy Markdown
Member

Fixes @exceptionless/core paths that silently dropped or corrupted events.

Bug Fix
parseQueryString throws URIError on ?discount=100%, so BrowserRequestInfoPlugin cancelled every event from that page; exclusions matched the still-encoded key (pass%77ord got past password); ?flag gave "undefined" Decode safely and keep the raw text on URIError, match exclusions on the decoded key, use "" for missing values, skip empty keys, split on the first =
getCookies split on every =, cutting off base64 values Split on the first = and decode the same safe way. Values are now URI-decoded too, which they weren't before
prune/stringify throw on a throwing getter, a throwing toJSON or a revoked Proxy. That cancelled error events and threw out of setProperty The bad value becomes undefined, the same way unsupported and circular values are dropped, and the rest of the object is kept
toJSON that returns itself or another toJSON object recursed with no limit Each nested toJSON call counts against the depth
One global seen set dropped shared references that aren't circular ({a: obj, b: obj} lost b); arrays and Errors weren't checked for cycles Only the objects on the current path are tracked, and arrays and Errors are checked too. True cycles are still pruned
EventPluginManager.run cancelled the event when any plugin threw, and the default NullLog hid it Logs Error running plugin "<name>": <message>. Continuing with the event. and keeps processing. context.cancelled = true still works. Startup and suspend log the same way; a failure there already didn't stop other plugins
@@log:*=off (or off for one source) didn't stop submitLog("msg") when the log had no level Logs without a recognized level are cancelled when the source's minimum level is off. Behavior is unchanged for every other level
DuplicateCheckerPlugin and EventExclusionPlugin only read @error, so @simple_error events were never de-duplicated and exception-type exclusions didn't apply Both use @error, and fall back to @simple_error when it's missing. Results for @error events are unchanged

Existing tests changed because they tested the old buggy behavior:

  • Utils.test.ts: "array reference removes duplicated object references" now expects [obj, obj] and is renamed "array reference keeps shared object references".
  • EventPluginManager.test.ts: "throwing error should stop plugin execution" and "should cancel via timeout" relied on a throw cancelling the event (there is no timeout). Both are replaced by tests where a plugin throws or rejects and the event keeps going, plus tests for cancel-then-throw and for startup and suspend failures.

No other existing test changed. Also updated the skill references plugins.md and troubleshooting.md.

Checks run: npm ci; npm test (26 files, 382 tests pass); npm run lint (ESLint and Prettier pass); npm run build for core, browser and node.

- parseQueryString/getCookies: decode safely, split on the first "=",
  match exclusions on the decoded key, use "" for missing values and
  skip empty keys.
- prune/stringify: drop values whose getter, toJSON or Proxy throws
  instead of throwing; cap nested toJSON calls by depth; track only
  ancestors for cycle detection (arrays and errors included) so shared,
  non-circular references are kept.
- EventPluginManager: a throwing plugin is logged with its name and the
  error, and the event continues instead of being cancelled.
- EventExclusionPlugin: logs without a level are cancelled when the
  source's minimum level is off; exception type exclusions also apply
  to @simple_error.
- DuplicateCheckerPlugin: de-duplicate @simple_error events.
Copilot AI balanced review requested due to automatic review settings December 2, 2026 01:06
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-02T01:17:38.905671Z 4cbe944 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI 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.

🟡 Changes recommended

Error formatting can still abort event processing, throwing array getters can discard healthy entries, and throwing Date serialization can make property updates fail.

3 open issues
What changed in this PR

This PR hardens shared core event processing so malformed data and plugin failures are less likely to discard events across SDK runtimes.

Changes:

  • Improves query/cookie parsing and defensive serialization.
  • Continues processing after plugin failures while preserving explicit cancellation.
  • Extends filtering and deduplication behavior, with regression tests and updated guidance.
File Description
packages/​core/​test/​Utils.test.ts Covers parsing and serialization edge cases.
packages/​core/​test/​plugins/​EventPluginManager.test.ts Tests failure recovery and explicit cancellation.
packages/​core/​test/​plugins/​default/​EventExclusionPlugin.test.ts Covers unlevelled logs and simple-error exclusions.
packages/​core/​test/​plugins/​default/​DuplicateCheckerPlugin.test.ts Tests simple-error deduplication.
packages/​core/​src/​Utils.ts Hardens parsing, serialization, and cycle handling.
packages/​core/​src/​plugins/​EventPluginManager.ts Continues after plugin failures and improves logging.
packages/​core/​src/​plugins/​default/​EventExclusionPlugin.ts Applies missing-level and simple-error filtering.
packages/​core/​src/​plugins/​default/​DuplicateCheckerPlugin.ts Adds simple-error fallback.
.agents/​skills/​exceptionless-javascript/​references/​troubleshooting.md Explains filtering and plugin-failure diagnostics.
.agents/​skills/​exceptionless-javascript/​references/​plugins.md Documents revised plugin-failure behavior.

Review effort: Balanced

Comment thread packages/core/src/Utils.ts Resolved
Comment thread packages/core/src/Utils.ts Resolved
…aves

- Read array elements one at a time so a throwing index getter drops
  only that element.
- Serialize a Date with an overridden toJSON inside prune, where a throw
  drops only that value.
- Format plugin errors without throwing (a thrown Symbol made the catch
  handler itself throw).
@ejsmith
ejsmith marked this pull request as draft December 2, 2026 03:20
seen: WeakSet<object> = new WeakSet(),
parentIsArray: boolean = false
): unknown {
function pruneImpl(value: unknown, maxDepth: number, currentDepth: number = 10, ancestors: Set<object> = new Set(), parentIsArray: boolean = false): unknown {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we need a ton of coverage for this if we are changing it and benchmarks. I did a ton of work to make sure this was performant and error free

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[AGENT] I ran a focused synthetic benchmark of stringify() on Node 24.22.3, comparing 54ac83f with 4cbe944. Across 10 warmed, alternating-order pairs, median paired time was 4.1% higher for a 111-byte log (1.153 → 1.200 µs per call) and 2.4% higher for a 1,431-byte nested error/request (14.117 → 14.424 µs). Both revisions produced byte-identical JSON. This covers two ordinary payloads. Browser and device performance, allocations, and malformed or cyclic inputs remain open.

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.

3 participants