Fix excessive logging in create_pr.py that creates 43MB+ log files#2000
Fix excessive logging in create_pr.py that creates 43MB+ log files#2000mohammedahmed18 wants to merge 1 commit intomainfrom
Conversation
**Problem:**
Line 38 of create_pr.py logged all keys from function_to_tests dictionary
using `list(function_to_tests.keys())`. For large codebases like budibase
(1012 functions), this creates massive log files (43MB+) with a single
DEBUG statement printing thousands of function names.
**Root Cause:**
Debug logging statement was designed for small projects but became
problematic when used with monorepos containing hundreds of packages.
**Evidence:**
- Trace ID: 3d2ad2f0-254a-4401-9c93-84f691acabf0 (43MB log, 534K lines)
- Line 533922 shows list of 1000+ function keys in single log entry
- Affects 4/22 logs (18%) in recent optimization run
- Each occurrence adds ~100KB to log file
**Fix:**
Changed line 38 from:
logger.debug(f"[PR-DEBUG] function_to_tests keys: {list(function_to_tests.keys())}")
to:
logger.debug(f"[PR-DEBUG] function_to_tests has {len(function_to_tests)} keys")
This logs only the count instead of the full list, reducing log output
from ~100KB to ~50 bytes per call.
**Impact:**
- Severity: MEDIUM (doesn't break functionality, but bloats logs)
- Systematic: Reproducible on every optimization run with large codebases
- Benefits: Significantly reduces log file sizes for monorepo projects
**Testing:**
- Added 2 regression tests in test_create_pr_logging_bug.py
- Tests verify count is logged, not full key list
- Tests verify log output stays under 10KB (vs 100KB+ before)
- All existing tests pass
- Linting passes (uv run prek)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
Claude finished @mohammedahmed18's task in 2m 18s —— View job PR Review Summary
Prek Checks
Code ReviewThe fix itself is correct. Changing However, there are two broader concerns: 1. The
|
Problem
Line 38 of
create_pr.pylogged all keys from thefunction_to_testsdictionary usinglist(function_to_tests.keys()). For large codebases like budibase (1012 functions), this creates massive log files (43MB+) with a single DEBUG statement printing thousands of function names.Evidence
3d2ad2f0-254a-4401-9c93-84f691acabf0(43MB log, 534K lines)Root Cause
Debug logging statement at line 38 was designed for small projects but became problematic when used with monorepos containing hundreds of packages:
Fix
Changed to log only the count:
This reduces log output from ~100KB to ~50 bytes per call.
Testing
test_create_pr_logging_bug.pyuv run prek)Impact
Related Issues
Part of comprehensive bug-fixing effort for Codeflash optimization stability.