{"record":{"id":"061998cf39bf03e3","repo":"ruvnet/RuView","slug":"compression-level-must-be-between-1-and-9","errorCode":null,"errorMessage":"Compression level must be between 1 and 9","messagePattern":"Compression level must be between 1 and 9","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"archive/v1/src/config/domains.py","lineNumber":222,"sourceCode":"    timeout: int = Field(default=300, description=\"Connection timeout in seconds\")\n    max_connections: int = Field(default=100, description=\"Maximum concurrent connections\")\n    \n    # Data filtering\n    min_confidence: float = Field(default=0.5, description=\"Minimum confidence for streaming\")\n    include_metadata: bool = Field(default=True, description=\"Include metadata in stream\")\n    \n    @validator(\"fps\")\n    def validate_fps(cls, v):\n        \"\"\"Validate FPS value.\"\"\"\n        if not 1 <= v <= 60:\n            raise ValueError(\"FPS must be between 1 and 60\")\n        return v\n    \n    @validator(\"compression_level\")\n    def validate_compression_level(cls, v):\n        \"\"\"Validate compression level.\"\"\"\n        if not 1 <= v <= 9:\n            raise ValueError(\"Compression level must be between 1 and 9\")\n        return v\n\n\nclass AlertConfig(BaseModel):\n    \"\"\"Configuration for alerts and notifications.\"\"\"\n    \n    # Alert types\n    enable_pose_alerts: bool = Field(default=False, description=\"Enable pose-based alerts\")\n    enable_activity_alerts: bool = Field(default=False, description=\"Enable activity-based alerts\")\n    enable_zone_alerts: bool = Field(default=False, description=\"Enable zone-based alerts\")\n    enable_system_alerts: bool = Field(default=True, description=\"Enable system alerts\")\n    \n    # Thresholds\n    confidence_threshold: float = Field(default=0.8, description=\"Alert confidence threshold\")\n    duration_threshold: int = Field(default=5, description=\"Alert duration threshold in seconds\")\n    \n    # Activities that trigger alerts\n    alert_activities: List[ActivityType] = Field(","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/archive/v1/src/config/domains.py#L204-L240","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\nstreaming = StreamingConfig(compression_level=0)\n\n# after\nstreaming = StreamingConfig(compression_level=1)","handlingStrategy":"validation","validationCode":"level = cfg.get(\"compression_level\", 6)\nassert isinstance(level, int) and 1 <= level <= 9, f\"compression_level must be 1-9, got {level!r} (0 and -1 are NOT allowed here)\"","typeGuard":"def is_valid_compression_level(v) -> bool:\n    return isinstance(v, int) and not isinstance(v, bool) and 1 <= v <= 9","tryCatchPattern":"from pydantic import ValidationError\ntry:\n    streaming = StreamingConfig(**cfg[\"streaming\"])\nexcept ValidationError as e:\n    if any(err[\"loc\"][-1] == \"compression_level\" for err in e.errors()):\n        raise ValueError(\"compression_level must be 1-9 (zlib's 0 and -1 are not accepted)\") from e\n    raise","preventionTips":["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"],"tags":["pydantic","validation","config","compression","streaming","python"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}