fix(core,webapp): redact sensitive fields in logs by default and cap their size - #4401
Conversation
…their size The Logger used to only redact keys a caller explicitly listed, and most call sites listed none. It now applies a default set of sensitive key names (tokens, passwords, api keys, payloads, headers, email, and more) to every log line, matched case-insensitively and recursively, no matter how many arguments a log call passes. String values shaped like a bearer token or API key are redacted even under an unlisted key. Logged errors now run their message, stack and metadata through the same redaction and size limits as the rest of the line, instead of being copied through untouched. Long strings and large arrays are truncated with a marker instead of written out in full. The webapp's Sentry reporting now applies the same redaction to the extra data it sends, so a field that gets filtered on stdout is filtered on its way to Sentry too.
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughThe logging system now applies default and caller-provided key filtering, secret-pattern detection, string and array truncation, and recursion limits. Structured errors use the same redaction pipeline for messages, stacks, metadata, and nested errors. The webapp’s Sentry error-reporting path redacts flattened log arguments before sending exception or message payloads. Tests cover logger output, the standalone 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
@trigger.dev/build
trigger.dev
@trigger.dev/core
@trigger.dev/python
@trigger.dev/react-hooks
@trigger.dev/redis-worker
@trigger.dev/rsc
@trigger.dev/schema-to-json
@trigger.dev/sdk
commit: |
ericallam
left a comment
There was a problem hiding this comment.
This PR has a lot of changes and just want to make sure that we haven't introduced any ELU regressions here, anything with filtering or detecting the length and stuff has the chance of doing that. Lets make sure the filtering and stuff only happens if we are going to log (e.g. if its a debug log, and the logLevel is set to info, none of this work happens
|
@ericallam did a bunch of microbenchmarks when I reviewed this a few days ago. Briefly:
Still net win if we disable debug logging. |
Summary
Structured logs now redact common credential and sensitive-data fields by
default, including nested values and error metadata. Long strings and arrays
are capped so a single log entry cannot grow without bound.
The same redaction applies to error-reporting extras. Unchanged values retain
their existing references, avoiding unnecessary cloning on ordinary log calls.