Commit 3ee8100
committed
UN-2813 [FIX] Sanitize CLI queue list to prevent invalid queue names
Fix bug where malformed --queues input causes worker to crash.
**Problem:**
CLI queue list was returned without sanitization, allowing invalid
queue names to reach Celery/Temporal and crash the worker:
Examples of problematic input:
- `--queues foo,` → ["foo", ""] (empty string)
- `--queues foo, bar` → ["foo", " bar"] (whitespace)
- `--queues ,,,` → ["", "", ""] (all empty)
**Inconsistency:**
Environment variable TASK_QUEUES was properly sanitized (line 97),
but CLI --queues was not (line 88-90), creating inconsistent behavior.
**Solution:**
Apply same sanitization to CLI queues as env queues:
```python
queues = [q.strip() for q in cli_queues if q and q.strip()]
if not queues:
raise ValueError("No queues specified via --queues after trimming...")
```
**Changes:**
1. ✅ Strip whitespace from each queue name
2. ✅ Filter out empty/whitespace-only entries
3. ✅ Validate at least one valid queue remains
4. ✅ Fail fast with clear error message
**Impact:**
- ✅ Prevents worker crashes from malformed queue input
- ✅ Consistent sanitization for CLI and env vars
- ✅ Better error messages for invalid input
- ✅ Worker starts reliably with clean queue list
**Examples:**
```bash
# Before: Crashes
--queues foo, # → ["foo", ""]
# After: Works
--queues foo, # → ["foo"]
# Before: Silent corruption
--queues " foo , bar " # → [" foo ", " bar "]
# After: Clean
--queues " foo , bar " # → ["foo", "bar"]
```
Resolves: CodeRabbit comment #2386596269
Related: #15551 parent 881e0e5 commit 3ee8100
1 file changed
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
90 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
91 | 96 | | |
92 | 97 | | |
93 | 98 | | |
| |||
0 commit comments