ruvnet/RuView · error · ValueError
Compression level must be between 1 and 9
Error message
Compression level must be between 1 and 9
What it means
Pydantic v1 @validator on StreamingConfig.compression_level in archive/v1/src/config/domains.py. It enforces 1 <= level <= 9, mirroring gzip/zlib compression levels. 0 (no compression) and 10 (extra compression) are both rejected, which surprises people who know zlib allows 0. Surfaced as pydantic.ValidationError at construction or when loading the 'streaming' section of a domain config.
Source
Thrown at archive/v1/src/config/domains.py:222
timeout: int = Field(default=300, description="Connection timeout in seconds")
max_connections: int = Field(default=100, description="Maximum concurrent connections")
# Data filtering
min_confidence: float = Field(default=0.5, description="Minimum confidence for streaming")
include_metadata: bool = Field(default=True, description="Include metadata in stream")
@validator("fps")
def validate_fps(cls, v):
"""Validate FPS value."""
if not 1 <= v <= 60:
raise ValueError("FPS must be between 1 and 60")
return v
@validator("compression_level")
def validate_compression_level(cls, v):
"""Validate compression level."""
if not 1 <= v <= 9:
raise ValueError("Compression level must be between 1 and 9")
return v
class AlertConfig(BaseModel):
"""Configuration for alerts and notifications."""
# Alert types
enable_pose_alerts: bool = Field(default=False, description="Enable pose-based alerts")
enable_activity_alerts: bool = Field(default=False, description="Enable activity-based alerts")
enable_zone_alerts: bool = Field(default=False, description="Enable zone-based alerts")
enable_system_alerts: bool = Field(default=True, description="Enable system alerts")
# Thresholds
confidence_threshold: float = Field(default=0.8, description="Alert confidence threshold")
duration_threshold: int = Field(default=5, description="Alert duration threshold in seconds")
# Activities that trigger alerts
alert_activities: List[ActivityType] = Field(View on GitHub (pinned to 4685618388)
Solutions
- Choose a level in 1-9; use 1 for lowest latency, 9 for smallest payload
- To approximate 'no compression', use level 1 rather than 0
- Replace zlib-style constants (-1 default, 0 none, 9 max) with 1-9 values before loading the config
- Validate config files in CI with a config lint step to catch this before deploy
Example fix
# before streaming = StreamingConfig(compression_level=0) # after streaming = StreamingConfig(compression_level=1)
Defensive patterns
Strategy: validation
Validate before calling
level = cfg.get("compression_level", 6)
assert isinstance(level, int) and 1 <= level <= 9, f"compression_level must be 1-9, got {level!r} (0 and -1 are NOT allowed here)" Type guard
def is_valid_compression_level(v) -> bool:
return isinstance(v, int) and not isinstance(v, bool) and 1 <= v <= 9 Try / catch
from pydantic import ValidationError
try:
streaming = StreamingConfig(**cfg["streaming"])
except ValidationError as e:
if any(err["loc"][-1] == "compression_level" for err in e.errors()):
raise ValueError("compression_level must be 1-9 (zlib's 0 and -1 are not accepted)") from e
raise Prevention
- Do not copy zlib level constants (0 = none, -1 = default) into this config
- Use 1-9 only; use 1 when you want minimal compression overhead
- Lint config files for compression_level outside 1-9 before deployment
When it happens
Trigger: compression_level=0 trying to disable compression for debugging; compression_level=10 assuming zlib-style 'max' semantics; compression_level=-1 (zlib default) copied from zlib docs.
Common situations: Porting zlib/gzip defaults (0 and -1 are legal there, not here); debugging bandwidth by turning compression off; copying configs from tools with 1-10 or 0-100 scales.
Related errors
- FPS must be between 1 and 60
- Threshold must be between 0.0 and 1.0
- Failed to load domain configuration: {e}
- Environment must be one of: {allowed_environments}
- Stream FPS must be between 1 and 60
AI-assisted analysis of ruvnet/RuView@4685618388 (2026-08-16).
Data as JSON: /api/errors/061998cf39bf03e3.
Report an issue: GitHub.