Skip to content

Shed oversized client errors, pause on rejected keys and validate audit envelopes - #12

Merged
albertovincenzi merged 2 commits into
mainfrom
fix/client-error-delivery-contract
Oct 19, 2026
Merged

albertovincenzi merged 2 commits into
mainfrom
fix/client-error-delivery-contract

Conversation

@albertovincenzi

Copy link
Copy Markdown
Contributor

Follow-up hardening for the browser/React Native error client and the Laravel audit capture.

Client errors (JS)

  • The endpoint is validated with a pattern instead of URL getters, which throw "not implemented" in React Native without a URL polyfill.
  • Events above 60 KB are shrunk before they are dropped: first breadcrumbs, then context (keeping session_id) and the raw stack beyond 8,000 characters. context.truncated records what was removed; only events still too large are dropped as oversize.
  • Frames passed to captureException and frames returned by beforeSend are normalised to the server contract (valid entries, cleaned URLs, at most 100).
  • A 401/403 means every event will be rejected. The queue is dropped and capture pauses for 1 minute, doubling up to 32 minutes while rejections continue. getStats().paused and a paused diagnostic expose the state; a successful delivery resets it.
  • installBrowserErrors returns the existing installation for the same window instead of duplicating listeners, and throws a clear error where no window exists (SSR).
  • typesVersions makes the browser, react-native, nuxt and react subpaths resolve under moduleResolution: node.

Audit (Laravel)

  • An enum cast in auditFields() made AuditEvent::diff() throw and failed the model save. Snapshots and canonical() now record the backing value or the case name.
  • description, actor.label, redacted_fields and origin.* are validated, and unknown keys in subject, actor, origin and changes are rejected. An invalid envelope now fails the write instead of reaching the outbox and failing every publish.
  • Identifier and text lengths are counted in UTF-16 code units, as the backend does.

Validation: npm run typecheck:errors, npm run build:errors, vitest 136/136 (5 new tests); phpunit Unit 152/152 (2 new tests).

Known issue, not caused by this change: npm run build fails in the DTS step because @confluentinc/kafka-javascript is not installed after the lockfile refresh in 0c462c9. The errors build and the ESM/CJS bundles succeed. The pre-commit secret check also passes a pattern starting with ----- to grep without -e, so its private-key check does not run.

albertovincenzi and others added 2 commits October 17, 2026 06:36
- Validate the endpoint with a pattern instead of URL getters, which throw
  in React Native without a URL polyfill.
- Shrink events above 60 KB in two steps (breadcrumbs, then context and raw
  stack) before dropping them; context.truncated records what was removed.
- Normalise caller frames and beforeSend output to the server contract
  (at most 100 valid frames).
- On 401/403 drop the queue and pause capture for 1 minute, doubling up to
  32 minutes; expose getStats().paused and a "paused" diagnostic.
- installBrowserErrors returns the existing installation for the same
  window and throws when no window exists.
- Add typesVersions so subpath imports resolve with moduleResolution node.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- An enum cast in auditFields() made diff() throw and failed the model
  save. Snapshots and canonical() now record the backing value or case name.
- Validate description, actor.label, redacted_fields and origin fields, and
  reject unknown keys in subject, actor, origin and changes, so an invalid
  envelope fails the write instead of being stuck in the outbox.
- Count identifier and text lengths in UTF-16 code units like the backend.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@albertovincenzi
albertovincenzi merged commit 70823eb into main Oct 19, 2026
5 checks passed
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.

1 participant