Skip to content

Commit cbfcfab

Browse files
UN-2813 [FIX] Remove unsupported log_level from structlog.configure
Fix critical bug causing CLI to crash with TypeError on startup. **Problem:** structlog.configure() does not accept a `log_level` keyword argument. Passing it raises TypeError, causing the CLI to fail immediately: ``` TypeError: configure() got an unexpected keyword argument 'log_level' ``` **Root Cause:** Line 35 in cli/main.py incorrectly passed log_level to structlog.configure: ```python structlog.configure( ..., log_level=log_level.upper(), # ❌ Not a valid parameter ) ``` **Solution:** 1. Added `import logging` 2. Configure log level via standard library before structlog: ```python logging.basicConfig(level=log_level.upper()) ``` 3. Removed unsupported `log_level` parameter from structlog.configure() **Impact:** - ✅ CLI now starts without TypeError - ✅ Log level control preserved via logging.basicConfig - ✅ Structured logging configuration intact - ✅ All CLI commands work correctly **Testing:** Before: CLI crashes on any invocation After: CLI starts and respects --log-level flag Resolves: CodeRabbit comment #2386596263 Related: #1555
1 parent 9819f80 commit cbfcfab

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

  • task-backend/src/unstract/task_backend/cli

task-backend/src/unstract/task_backend/cli/main.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Main CLI entry point for task backend worker."""
22

33
import argparse
4+
import logging
45
import signal
56
import sys
67

@@ -15,6 +16,9 @@
1516

1617
def setup_logging(log_level: str = "INFO", structured: bool = True) -> None:
1718
"""Setup structured logging."""
19+
# Configure standard logging level first
20+
logging.basicConfig(level=log_level.upper())
21+
1822
processors = [
1923
structlog.stdlib.filter_by_level,
2024
structlog.stdlib.add_logger_name,
@@ -32,7 +36,6 @@ def setup_logging(log_level: str = "INFO", structured: bool = True) -> None:
3236
wrapper_class=structlog.stdlib.BoundLogger,
3337
logger_factory=structlog.stdlib.LoggerFactory(),
3438
cache_logger_on_first_use=True,
35-
log_level=log_level.upper(),
3639
)
3740

3841

0 commit comments

Comments
 (0)