Enhance logging by adding content field redaction#1100
Conversation
…ted the logger utility to redact fields containing email/message content unless debug logs are enabled.
…uidelines. Added width class to HoverCard and improved content handling. Modified ResultDisplayContent to append a URL to action content. Updated search tips to clarify usage of plain text queries without field prefixes.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. WalkthroughThe PR normalizes Gmail-style search prefix handling across the system. Changes include removing search prefixes (subject:, label:, etc.) from AI agent prompts and Microsoft Graph queries, updating logging redaction logic for content fields, and applying overflow-hidden styling to HoverCard components. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
Poem
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (5)
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 |
| processed[key] = !!value; | ||
| } | ||
| // Redact content fields in production (unless debug logs enabled) | ||
| else if (CONTENT_FIELD_NAMES.has(key) && !env.ENABLE_DEBUG_LOGS) { |
There was a problem hiding this comment.
CONTENT_FIELD_NAMES are redacted whenever !env.ENABLE_DEBUG_LOGS, but the comment says this should only happen in production. Consider adding env.NODE_ENV === "production" to the condition so text/body aren’t hidden in dev/test.
| else if (CONTENT_FIELD_NAMES.has(key) && !env.ENABLE_DEBUG_LOGS) { | |
| else if (CONTENT_FIELD_NAMES.has(key) && env.NODE_ENV === "production" && !env.ENABLE_DEBUG_LOGS) { |
🚀 Reply to ask Macroscope to explain or update this suggestion.
👍 Helpful? React to give us feedback.
| content: | ||
| action.content + | ||
| "https://www.google.comasdjhgaghjdsghjasdgjasdjhasd", |
There was a problem hiding this comment.
Suggest removing the hardcoded URL concatenation to action.content. It looks like leftover debug code and corrupts displayed content; use action.content as-is.
| content: | |
| action.content + | |
| "https://www.google.comasdjhgaghjdsghjasdgjasdjhasd", | |
| content: action.content, |
🚀 Reply to ask Macroscope to explain or update this suggestion.
👍 Helpful? React to give us feedback.
There was a problem hiding this comment.
2 issues found across 5 files
Prompt for AI agents (all 2 issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="apps/web/app/(app)/[emailAccountId]/assistant/ResultDisplay.tsx">
<violation number="1" location="apps/web/app/(app)/[emailAccountId]/assistant/ResultDisplay.tsx:143">
P0: Debug/test code left in production: This line appends a hardcoded nonsensical URL string to `action.content`, corrupting the displayed content. This appears to be accidental test data that should be removed.</violation>
</file>
<file name="apps/web/utils/logger.ts">
<violation number="1" location="apps/web/utils/logger.ts:255">
P2: Code doesn't match documented behavior: comment says content fields are "redacted in production" but the condition doesn't check for production environment. This will redact content in dev/test when `ENABLE_DEBUG_LOGS` is false, which may hide useful debugging information during development.</violation>
</file>
Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR
| folderName: action.folderName, | ||
| content: action.content, | ||
| content: | ||
| action.content + |
There was a problem hiding this comment.
P0: Debug/test code left in production: This line appends a hardcoded nonsensical URL string to action.content, corrupting the displayed content. This appears to be accidental test data that should be removed.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/web/app/(app)/[emailAccountId]/assistant/ResultDisplay.tsx, line 143:
<comment>Debug/test code left in production: This line appends a hardcoded nonsensical URL string to `action.content`, corrupting the displayed content. This appears to be accidental test data that should be removed.</comment>
<file context>
@@ -136,7 +139,9 @@ export function ResultDisplayContent({ result }: { result: RunRulesResult }) {
folderName: action.folderName,
- content: action.content,
+ content:
+ action.content +
+ "https://www.google.comasdjhgaghjdsghjasdgjasdjhasd",
to: action.to,
</file context>
| processed[key] = !!value; | ||
| } | ||
| // Redact content fields in production (unless debug logs enabled) | ||
| else if (CONTENT_FIELD_NAMES.has(key) && !env.ENABLE_DEBUG_LOGS) { |
There was a problem hiding this comment.
P2: Code doesn't match documented behavior: comment says content fields are "redacted in production" but the condition doesn't check for production environment. This will redact content in dev/test when ENABLE_DEBUG_LOGS is false, which may hide useful debugging information during development.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/web/utils/logger.ts, line 255:
<comment>Code doesn't match documented behavior: comment says content fields are "redacted in production" but the condition doesn't check for production environment. This will redact content in dev/test when `ENABLE_DEBUG_LOGS` is false, which may hide useful debugging information during development.</comment>
<file context>
@@ -247,6 +251,10 @@ function hashSensitiveFields<T>(obj: T, depth = 0): T {
processed[key] = !!value;
}
+ // Redact content fields in production (unless debug logs enabled)
+ else if (CONTENT_FIELD_NAMES.has(key) && !env.ENABLE_DEBUG_LOGS) {
+ processed[key] = !!value;
+ }
</file context>
Redact content fields in production logs by replacing
textandbodyvalues whenENABLE_DEBUG_LOGSis disabled inutils/logger.tsAdds content-field redaction in
hashSensitiveFieldsand constrains hover card width while hiding overflow; also stripssubject:andlabel:prefixes from Outlook queries.📍Where to Start
Start with
hashSensitiveFieldsin apps/web/utils/logger.ts to review the new content-field handling.📊 Macroscope summarized e4bf975. 5 files reviewed, 2 issues evaluated, 0 issues filtered, 2 comments posted
🗂️ Filtered Issues
Summary by CodeRabbit
Style
Improvements
✏️ Tip: You can customize this high-level summary in your review settings.