{"record":{"id":"09b53920260603c5","repo":"unclecode/crawl4ai","slug":"score-threshold-must-be-between-0-0-and-1-0","errorCode":null,"errorMessage":"score_threshold must be between 0.0 and 1.0","messagePattern":"score_threshold must be between 0\\.0 and 1\\.0","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"crawl4ai/async_configs.py","lineNumber":1205,"sourceCode":"        self.include_external = include_external\n        self.include_patterns = include_patterns\n        self.exclude_patterns = exclude_patterns\n        self.concurrency = concurrency\n        self.timeout = timeout\n        self.max_links = max_links\n        self.query = query\n        self.score_threshold = score_threshold\n        self.verbose = verbose\n        \n        # Validation\n        if concurrency <= 0:\n            raise ValueError(\"concurrency must be positive\")\n        if timeout <= 0:\n            raise ValueError(\"timeout must be positive\")\n        if max_links <= 0:\n            raise ValueError(\"max_links must be positive\")\n        if score_threshold is not None and not (0.0 <= score_threshold <= 1.0):\n            raise ValueError(\"score_threshold must be between 0.0 and 1.0\")\n        if not include_internal and not include_external:\n            raise ValueError(\"At least one of include_internal or include_external must be True\")\n    \n    @staticmethod\n    def from_dict(config_dict: Dict[str, Any]) -> \"LinkPreviewConfig\":\n        \"\"\"Create LinkPreviewConfig from dictionary (for backward compatibility).\"\"\"\n        if not config_dict:\n            return None\n        \n        return LinkPreviewConfig(\n            include_internal=config_dict.get(\"include_internal\", True),\n            include_external=config_dict.get(\"include_external\", False),\n            include_patterns=config_dict.get(\"include_patterns\"),\n            exclude_patterns=config_dict.get(\"exclude_patterns\"),\n            concurrency=config_dict.get(\"concurrency\", 10),\n            timeout=config_dict.get(\"timeout\", 5),\n            max_links=config_dict.get(\"max_links\", 100),\n            query=config_dict.get(\"query\"),","sourceCodeStart":1187,"sourceCodeEnd":1223,"githubUrl":"https://github.com/unclecode/crawl4ai/blob/7e801521428ee12509994d39151006f64055ebe3/crawl4ai/async_configs.py#L1187-L1223","documentation":"LinkPreviewConfig accepts an optional score_threshold used to filter links by relevance (e.g. cosine similarity against query). Valid values are a fraction between 0.0 and 1.0; anything outside is rejected because the comparison would be meaningless.","triggerScenarios":"score_threshold=5, -0.1, 1.5, or passing a percentage (e.g. 70 meaning 70%) instead of a fraction.","commonSituations":"Porting thresholds expressed as percentages from other tools; env/config values scaled 0–100.","solutions":["Pass a fraction in [0.0, 1.0], e.g. score_threshold=0.7","If your config stores percentages, divide by 100 before constructing","Leave it None to disable relevance filtering"],"exampleFix":"// before\ncfg = LinkPreviewConfig(query=\"docs\", score_threshold=70)\n// after\ncfg = LinkPreviewConfig(query=\"docs\", score_threshold=0.7)","handlingStrategy":"validation","validationCode":"if score_threshold is not None:\n    score_threshold = float(score_threshold)\n    if score_threshold > 1:  # assume percentage\n        score_threshold /= 100.0\n    assert 0.0 <= score_threshold <= 1.0, \"score_threshold must be in [0,1]\"","typeGuard":"def valid_threshold(t) -> bool:\n    return t is None or (isinstance(t, (int, float)) and 0.0 <= t <= 1.0)","tryCatchPattern":null,"preventionTips":["Store thresholds as fractions in config files","Auto-divide values > 1 by 100 at the config boundary"],"tags":["validation","configuration","link-preview","threshold"],"backgroundTag":null,"analyzedSha":"7e801521428ee12509994d39151006f64055ebe3","analyzedAt":"2026-08-14T20:46:20.673Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}