0032. No personal data or secrets in server logs, enforced by one redacting logger
- Status: Accepted
- Date: 2026-11-11
Context
Section titled “Context”ADR 0007 keeps secrets out of logs, but says nothing about personal data. Error messages can quote customer emails and IP addresses as well as credentials, and server logs sit outside the project store: they are not covered by customer deletion (ADR 0023) or by retention, so personal data in them is hard to find and erase under the GDPR. Before this ADR, the HTTP and MCP surfaces redacted credentials, but the Worker’s wake and delivery logs and the ProjectDO’s alarm log printed raw error objects, and the secret prefixes were listed in two places.
The maintainer decided on 2026-11-11 that logs must not contain personal data, and that email addresses are masked like secrets.
Decision
Section titled “Decision”- Server logs contain no secrets and no personal data. This extends invariant 6 of ADR 0007 from secrets to personal data, for logs.
- Every server-side log line goes through
logErrorincore/src/log.ts. It logs a message and, at most, the error’s name and message, both passed throughredactForLog. Raw error objects, payloads, and records are never logged. redactForLogmasks:- credentials: every prefix in
CREDENTIAL_PREFIXES(core/src/auth, the one list ofcl_sk_,cl_rk_,cl_pk_,cl_whsec_, and, amended for ADR 0033, the approval link secretcl_apsec_, and, amended for ADR 0036, the unsubscribe tokencl_unsub_) and Bearer values; - email addresses, including non-ASCII ones, as
[email]; - IPv4 addresses, and IPv6 addresses in full form or compressed with at least two groups before
::, as[ip].
- credentials: every prefix in
- Log messages identify things by the IDs we generate (
prj_,msg_) and by kinds (wake item message failed), never by customer external IDs, which are often email addresses, or by customer attributes. - Credentials in logs show only their prefix (
cl_sk_[redacted]), stricter than the prefix and last four characters that ADR 0026 allows. - This covers the log lines our code writes. What the platform records itself (uncaught exceptions, request metadata in Workers Logs or Logpush) is set by deployment configuration and is tracked in
docs/architecture.mdopen items. - The ESLint rules
no-consoleandno-restricted-properties(globalThis.console) fail on anyconsoleuse outsidecore/src/log.tsand tests;core/test/lint-bans.test.tschecks them. Lint sees direct use only: an alias (const c = console) or a localdeclare const consolegets past it, so review still applies.
Consequences
Section titled “Consequences”- Masking is by pattern, so it is a safety net, not a guarantee: names, free-text attributes, and other personal data that has no fixed shape are not caught. Messages must not include them in the first place.
- Stacks and causes are not logged; a failure is investigated from its IDs and error name. This costs some debuggability.
- The patterns can over-mask text shaped like an address (a four-part version number such as
1.2.3.4); logs lose that detail. core/src/log.tsdeclaresconsoleitself, since core has no platform types (ADR 0018);consoleexists in every runtime we target.- A structured logger or a log sink port, if needed later, replaces
logError’s body; call sites and the lint rule stay. - The
check-tenant-safetyskill checks log lines against this ADR.