{"record":{"id":"0d41e845ca54df6f","repo":"NanmiCoder/MediaCrawler","slug":"zhihu-begin-i-nvalid-login-type-currently-only-su","errorCode":null,"errorMessage":"[ZhiHu.begin]I nvalid Login Type Currently only supported qrcode or phone or cookies ...","messagePattern":"\\[ZhiHu\\.begin\\]I nvalid Login Type Currently only supported qrcode or phone or cookies \\.\\.\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"media_platform/zhihu/login.py","lineNumber":75,"sourceCode":"        \"\"\"\n        current_cookie = await self.browser_context.cookies()\n        _, cookie_dict = utils.convert_cookies(current_cookie)\n        current_web_session = cookie_dict.get(\"z_c0\")\n        if current_web_session:\n            return True\n        return False\n\n    async def begin(self):\n        \"\"\"Start login zhihu\"\"\"\n        utils.logger.info(\"[ZhiHu.begin] Begin login zhihu ...\")\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(\"[ZhiHu.begin]I nvalid Login Type Currently only supported qrcode or phone or cookies ...\")\n\n    async def login_by_mobile(self):\n        \"\"\"Login zhihu by mobile\"\"\"\n        # todo implement login by mobile\n\n    async def login_by_qrcode(self):\n        \"\"\"login zhihu website and keep webdriver login state\"\"\"\n        utils.logger.info(\"[ZhiHu.login_by_qrcode] Begin login zhihu by qrcode ...\")\n        qrcode_img_selector = \"canvas.Qrcode-qrcode\"\n        # find login qrcode\n        base64_qrcode_img = await utils.find_qrcode_img_from_canvas(\n            self.context_page,\n            canvas_selector=qrcode_img_selector\n        )\n        if not base64_qrcode_img:\n            utils.logger.info(\"[ZhiHu.login_by_qrcode] login failed , have not found qrcode please check ....\")\n            if not base64_qrcode_img:\n                sys.exit()","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/NanmiCoder/MediaCrawler/blob/d6f7c5bb906b6dac40ddf343ef9e26438a3de092/media_platform/zhihu/login.py#L57-L93","documentation":"ValueError raised by ZhiHuLogin.begin when config.LOGIN_TYPE is not 'qrcode', 'phone', or 'cookies'. Note that zhihu accepts 'cookies' (plural) and that its phone login is a stub ('todo implement login by mobile'), so even the accepted 'phone' value currently does nothing. Pure config-validation error.","triggerScenarios":"LOGIN_TYPE set to an unsupported literal, or set to 'cookie' (singular, weibo-style) which fails zhihu's check; also any typo/case mismatch.","commonSituations":"One shared LOGIN_TYPE reused across platforms while each platform checks different literals; user expects 'phone' to work and hits the unimplemented stub afterwards.","solutions":["Set LOGIN_TYPE to 'qrcode' or 'cookies' (plural) for zhihu.","Do not use 'phone' for zhihu yet - login_by_mobile is unimplemented.","Check the --lt CLI value for typos and case."],"exampleFix":"# before\nLOGIN_TYPE = \"cookie\"\n# after\nLOGIN_TYPE = \"cookies\"","handlingStrategy":"validation","validationCode":"import config\nassert config.LOGIN_TYPE in {\"qrcode\", \"phone\", \"cookies\"}, f\"bad LOGIN_TYPE: {config.LOGIN_TYPE!r}\"","typeGuard":"def is_valid_zhihu_login_type(value: str) -> bool:\n    return isinstance(value, str) and value in {\"qrcode\", \"phone\", \"cookies\"}","tryCatchPattern":null,"preventionTips":["Zhihu accepts 'cookies' (plural); 'phone' login is an unimplemented stub - use qrcode or cookies.","Validate LOGIN_TYPE at startup with a per-platform allowlist.","Keep CLI --lt values in sync with the platform's accepted literals."],"tags":["zhihu","login","config","validation"],"backgroundTag":null,"analyzedSha":"d6f7c5bb906b6dac40ddf343ef9e26438a3de092","analyzedAt":"2026-08-15T01:39:07.505Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}