Skip to content

Commit 39cc197

Browse files
rtibblesclaude
andcommitted
Document that exceptions must not be interpolated into log messages
Exception messages can contain sensitive data, and text interpolated into a log string cannot be filtered or redacted by logging handlers. Record the rule in the agent conventions and the code quality docs: log a static message and pass the exception via exc_info instead. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 2d9c070 commit 39cc197

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ kolibri/
132132

133133
## Key Conventions
134134

135-
**Python:** F-strings preferred. One import per line. `DateTimeTzField` for timestamps (not Django's `DateTimeField`). `UUIDField` from morango for syncable models. Descriptive migration names (no `_auto_`). All imports at file top — inline imports are only permitted to prevent circular imports.
135+
**Python:** F-strings preferred. One import per line. `DateTimeTzField` for timestamps (not Django's `DateTimeField`). `UUIDField` from morango for syncable models. Descriptive migration names (no `_auto_`). All imports at file top — inline imports are only permitted to prevent circular imports. Never interpolate exception messages into log strings (security risk — they can contain sensitive data); log a static message and pass `exc_info=True`.
136136

137137
**Vue:** PascalCase filenames. Component `name` must match filename. Use `computed()` for derived values.
138138

docs/code_quality.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ If something that "cannot happen" happens, crash — a dead program does less da
9393

9494
In Kolibri, Django REST Framework's exception handling will catch unhandled exceptions and return appropriate error responses — there is no need to wrap every view method in a try/except.
9595

96+
When you do catch and log an exception, never interpolate the exception message into the log string (``logger.error(f"Failed: {e}")``) — exception messages can contain sensitive data such as credentials, tokens, or personal information, and text baked into the message cannot be filtered or redacted by logging handlers. Log a static message and pass the exception via ``logger.error("Failed to save report.", exc_info=True)`` so it flows through the logging framework.
97+
9698

9799
Tell, don't ask
98100
---------------

0 commit comments

Comments
 (0)