{"record":{"id":"618372349b4aec01","repo":"ZhuLinsen/daily_stock_analysis","slug":"scope-value-is-required-when-scope-type-scope-typ","errorCode":null,"errorMessage":"scope_value is required when scope_type={scope_type}","messagePattern":"scope_value is required when scope_type=(.+?)","errorType":"validation","errorClass":"IntelligenceServiceError","httpStatus":400,"severity":"error","filePath":"src/services/intelligence_service.py","lineNumber":378,"sourceCode":"    def _normalize_source_fields(self, payload: Dict[str, Any]) -> Dict[str, Any]:\n        name = str(payload.get(\"name\") or \"\").strip()\n        url = str(payload.get(\"url\") or \"\").strip()\n        source_type = str(payload.get(\"source_type\") or \"rss\").strip().lower()\n        scope_type = str(payload.get(\"scope_type\") or \"market\").strip().lower()\n        scope_value = str(payload.get(\"scope_value\") or \"\").strip() or None\n        market = str(payload.get(\"market\") or \"cn\").strip().lower()\n        enabled = bool(payload.get(\"enabled\", True))\n        description = str(payload.get(\"description\") or \"\").strip() or None\n        if not name:\n            raise IntelligenceServiceError(\"source name is required\")\n        if not url:\n            raise IntelligenceServiceError(\"source url is required\")\n        if source_type not in _ALLOWED_SOURCE_TYPES:\n            raise IntelligenceServiceError(f\"unsupported source_type: {source_type}\")\n        if scope_type not in _ALLOWED_SCOPE_TYPES:\n            raise IntelligenceServiceError(f\"unsupported scope_type: {scope_type}\")\n        if scope_type in {\"symbol\", \"sector\"} and not scope_value:\n            raise IntelligenceServiceError(f\"scope_value is required when scope_type={scope_type}\")\n        if market not in _ALLOWED_MARKETS:\n            raise IntelligenceServiceError(f\"unsupported market: {market}\")\n        return {\n            \"name\": name[:100],\n            \"source_type\": source_type,\n            \"url\": url,\n            \"enabled\": enabled,\n            \"scope_type\": scope_type,\n            \"scope_value\": scope_value[:64] if scope_value else None,\n            \"market\": market,\n            \"description\": description,\n        }\n\n    def _validate_url(self, raw_url: str, *, allow_no_url: bool = False) -> None:\n        if allow_no_url and raw_url.startswith(\"no-url:intel:\"):\n            return\n        parsed = urlparse(raw_url)\n        if parsed.scheme.lower() not in {\"http\", \"https\"} or not parsed.netloc:","sourceCodeStart":360,"sourceCodeEnd":396,"githubUrl":"https://github.com/ZhuLinsen/daily_stock_analysis/blob/5159bd72e8373d215492dff122acc9d389e219c9/src/services/intelligence_service.py#L360-L396","documentation":"Error \"scope_value is required when scope_type={scope_type}\" thrown in ZhuLinsen/daily_stock_analysis.","triggerScenarios":"Thrown at src/services/intelligence_service.py:378 when the library encounters an invalid state.","commonSituations":"Raised when scope_value is missing for a scope_type that requires it; occurs when creating an intelligence source scoped to a market/stock without supplying the scope value.","solutions":["Provide scope_value for the chosen scope_type (e.g. a stock code or keyword).","If no scope is intended, use a scope_type that does not require a value.","Check the API request body to ensure scope_value is not empty or omitted."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5159bd72e8373d215492dff122acc9d389e219c9","analyzedAt":"2026-08-15T01:59:36.292Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}