Errors and Redaction
Which errors are captured, what's sent for each, and what redaction catches and misses.
Captured errors
Unhandled request errors are captured automatically. For one you handled yourself:
jstry {
syncFeeds()
} catch ( any e ) {
monitorCaptureException( e, { job: "syncFeeds" } )
}
monitorCaptureException() does nothing when the module is disabled and never throws, whatever it's given (a context that isn't a struct is sent as { value: ... }), so it's safe inside catch blocks.
Errors wait in a queue of maxBufferedErrors (500) until the next heartbeat. When it's full, the oldest is dropped and the heartbeat's droppedErrors counts it.
What's never sent
Request or response bodies, headers, cookies, form fields, query strings, session or application data, environment variables, source code. An error's context holds the route and HTTP method and nothing else, unless you add to it with monitorCaptureException().
Two things are sent as they are, in every mode: route names (the HTTP method and script path, or BoxExpress's route pattern) and an error's type. If your URLs carry a secret in the path itself, it will appear in the route.
errorDetail
errorDetail | Sent for each error |
|---|---|
"redacted" (default) | type, fingerprint, time, and the message, detail, stack trace and context after redaction |
"none" | type, fingerprint and time only. Message, detail and stack trace are empty, context is {} |
"full" | everything as it was thrown, unredacted. Stack traces are still cut to maxStackFrames |
What redaction catches
- Struct keys. In the context, any key that contains a
redactKeysentry has its value replaced with[redacted], at any depth. Case, hyphens and underscores are ignored and matching is by substring, sodbPassword,X-Api-Keyandapi_keyare all caught. So issessionCount: over-redacting is the intended way to fail. - Credentials in URLs.
jdbc:mysql://admin:hunter2@db/appbecomesjdbc:mysql://[redacted]@db/app. - Query strings. Every value after
?or&:/a?id=42&q=xbecomes/a?id=[redacted]&q=[redacted]. key=valueandkey: valuein text, for everyredactKeysentry, including JSON (escaped or not) andAuthorizationheaders with their scheme. ACookieheader is removed to the end of its line.- Bearer tokens anywhere in text.
- Your own patterns. Each
redactPatternsentry is applied to the message, detail, stack trace and every string in the context. A pattern that doesn't compile is skipped.
This error
textmessage: login failed password=hunter2 for bob
detail: GET /[email protected]&next=/home
context: { route: "POST /login", apiToken: "abc123" }
is sent as
textmessage: login failed password=[redacted] for bob
detail: GET /login?email=[redacted]&next=[redacted]
context: { route: "POST /login", apiToken: "[redacted]" }
A failing health check's detail gets the same treatment, and with errorDetail: "none" it's replaced by check failed.
What it misses
Redaction is pattern matching. A secret in free text with no recognisable key next to it (the code is 8841), or next to a key but without = or : (with password 'hunter2', <password>hunter2</password>), isn't caught unless a redactPatterns entry matches it. If that worries you, use errorDetail: "none".
A context is copied six levels deep and 500 values in all; the rest becomes [truncated]. Message, detail and stack trace are each cut at 8000 characters, in every mode.
Fingerprints
The fingerprint groups repeats of the same error: a SHA-1 of the exception type and the first five application frames of its stack. Runtime, JDK and web-server frames are skipped, since every throw shares them. When a stack has no application frames, those are used without line numbers.