{"record":{"id":"a4e59cab1aa69033","repo":"NanmiCoder/MediaCrawler","slug":"weibologin-begin-invalid-login-type-currently-on","errorCode":null,"errorMessage":"[WeiboLogin.begin] Invalid Login Type Currently only supported qrcode or phone or cookie ...","messagePattern":"\\[WeiboLogin\\.begin\\] Invalid Login Type Currently only supported qrcode or phone or cookie \\.\\.\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"media_platform/weibo/login.py","lineNumber":65,"sourceCode":"                 ):\n        config.LOGIN_TYPE = login_type\n        self.browser_context = browser_context\n        self.context_page = context_page\n        self.login_phone = login_phone\n        self.cookie_str = cookie_str\n        self.weibo_sso_login_url = \"https://passport.weibo.com/sso/signin?entry=miniblog&source=miniblog\"\n\n    async def begin(self):\n        \"\"\"Start login weibo\"\"\"\n        utils.logger.info(\"[WeiboLogin.begin] Begin login weibo ...\")\n        if config.LOGIN_TYPE == \"qrcode\":\n            await self.login_by_qrcode()\n        elif config.LOGIN_TYPE == \"phone\":\n            await self.login_by_mobile()\n        elif config.LOGIN_TYPE == \"cookie\":\n            await self.login_by_cookies()\n        else:\n            raise ValueError(\n                \"[WeiboLogin.begin] Invalid Login Type Currently only supported qrcode or phone or cookie ...\")\n\n\n    @retry(stop=stop_after_attempt(600), wait=wait_fixed(1), retry=retry_if_result(lambda value: value is False))\n    async def check_login_state(self, no_logged_in_session: str) -> bool:\n        \"\"\"\n            Check if the current login status is successful and return True otherwise return False\n            retry decorator will retry 20 times if the return value is False, and the retry interval is 1 second\n            if max retry times reached, raise RetryError\n        \"\"\"\n        current_cookie = await self.browser_context.cookies()\n        _, cookie_dict = utils.convert_cookies(current_cookie)\n        if cookie_dict.get(\"SSOLoginState\"):\n            return True\n        current_web_session = cookie_dict.get(\"WBPSESS\")\n        if current_web_session != no_logged_in_session:\n            return True\n        return False","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/NanmiCoder/MediaCrawler/blob/d6f7c5bb906b6dac40ddf343ef9e26438a3de092/media_platform/weibo/login.py#L47-L83","documentation":"Raised by WeiboLogin.begin when config.LOGIN_TYPE is not one of the three supported values 'qrcode', 'phone', or 'cookie'. It is a plain ValueError from config validation, thrown before any browser session work starts.","triggerScenarios":"LOGIN_TYPE set to an unsupported string (e.g. 'sms', 'account', trailing whitespace like 'cookie ') or left as a placeholder in the weibo section of the config.","commonSituations":"Editing config/base_config.py or passing --lt with a typo; copying a config from another platform that uses a different login-type vocabulary; case mismatch ('QRCode' vs 'qrcode').","solutions":["Set LOGIN_TYPE to exactly 'qrcode', 'phone', or 'cookie' in the weibo config (config/base_config.py or the platform config chain).","If passing via CLI, check the --lt argument value for typos and case.","Strip whitespace and lowercase the value before comparison if you control the config loader."],"exampleFix":"# before\nLOGIN_TYPE = \"qr code\"\n# after\nLOGIN_TYPE = \"qrcode\"","handlingStrategy":"validation","validationCode":"import config\nassert config.LOGIN_TYPE in {\"qrcode\", \"phone\", \"cookie\"}, f\"bad LOGIN_TYPE: {config.LOGIN_TYPE!r}\"","typeGuard":"def is_valid_weibo_login_type(value: str) -> bool:\n    return isinstance(value, str) and value in {\"qrcode\", \"phone\", \"cookie\"}","tryCatchPattern":null,"preventionTips":["Keep one canonical list of supported login types and validate config at startup.","Note the accepted literal differs per platform (weibo: 'cookie', xhs/zhihu: 'cookies').","Fail fast at config load rather than deep inside login flow."],"tags":["weibo","login","config","validation"],"backgroundTag":null,"analyzedSha":"d6f7c5bb906b6dac40ddf343ef9e26438a3de092","analyzedAt":"2026-08-15T01:39:07.505Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}