{"record":{"id":"e8f29552ff346990","repo":"NanmiCoder/MediaCrawler","slug":"baidutiebalogin-begin-invalid-login-type-currentl","errorCode":null,"errorMessage":"[BaiduTieBaLogin.begin]Invalid Login Type Currently only supported qrcode or phone or cookies ...","messagePattern":"\\[BaiduTieBaLogin\\.begin\\]Invalid Login Type Currently only supported qrcode or phone or cookies \\.\\.\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"media_platform/tieba/login.py","lineNumber":76,"sourceCode":"        current_cookie = await self.browser_context.cookies()\n        _, cookie_dict = utils.convert_cookies(current_cookie)\n        stoken = cookie_dict.get(\"STOKEN\")\n        ptoken = cookie_dict.get(\"PTOKEN\")\n        if stoken or ptoken:\n            return True\n        return False\n\n    async def begin(self):\n        \"\"\"Start login baidutieba\"\"\"\n        utils.logger.info(\"[BaiduTieBaLogin.begin] Begin login baidutieba ...\")\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(\"[BaiduTieBaLogin.begin]Invalid Login Type Currently only supported qrcode or phone or cookies ...\")\n\n    async def login_by_mobile(self):\n        \"\"\"Login baidutieba by mobile\"\"\"\n        pass\n\n    async def login_by_qrcode(self):\n        \"\"\"login baidutieba website and keep webdriver login state\"\"\"\n        utils.logger.info(\"[BaiduTieBaLogin.login_by_qrcode] Begin login baidutieba by qrcode ...\")\n        qrcode_img_selector = \"xpath=//img[@class='tang-pass-qrcode-img']\"\n        # find login qrcode\n        base64_qrcode_img = await utils.find_login_qrcode(\n            self.context_page,\n            selector=qrcode_img_selector\n        )\n        if not base64_qrcode_img:\n            utils.logger.info(\"[BaiduTieBaLogin.login_by_qrcode] login failed , have not found qrcode please check ....\")\n            # if this website does not automatically popup login dialog box, we will manual click login button\n            await asyncio.sleep(0.5)","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/NanmiCoder/MediaCrawler/blob/d6f7c5bb906b6dac40ddf343ef9e26438a3de092/media_platform/tieba/login.py#L58-L94","documentation":"Raised by BaiduTieBaLogin.begin (media_platform/tieba/login.py:76) when config.LOGIN_TYPE is not exactly 'qrcode', 'phone', or 'cookie'. Same dispatcher pattern as other platforms: an if/elif chain over the global config with a ValueError in the else branch. Note login_by_mobile is a stub ('pass'), so even 'phone' does nothing useful for Tieba.","triggerScenarios":"Starting the Tieba crawler with config.LOGIN_TYPE misspelled, wrong-cased (e.g. 'Cookie'), or set to an unsupported value like 'all'; the else branch raises before any login attempt.","commonSituations":"Shared LOGIN_TYPE across platforms where a value valid for one platform isn't valid for Tieba; typos in env vars; empty config after a migration.","solutions":["Set config.LOGIN_TYPE to exactly 'qrcode' or 'cookie' (lowercase) — 'phone' is unimplemented for Tieba","Log config.LOGIN_TYPE at startup to catch casing/whitespace mistakes","Extend the begin() dispatcher if you add a new login method"],"exampleFix":"# before\nLOGIN_TYPE=phone  # no-op stub for tieba\n\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_tieba_login_type(value: str) -> bool:\n    return isinstance(value, str) and value.strip().lower() in {\"qrcode\", \"phone\", \"cookie\"}","tryCatchPattern":null,"preventionTips":["Use 'qrcode' or 'cookie' for Tieba — 'phone' is an unimplemented stub","Normalize and validate LOGIN_TYPE at startup","Document per-platform login-type support in config comments"],"tags":["configuration","login","tieba","validation"],"backgroundTag":null,"analyzedSha":"d6f7c5bb906b6dac40ddf343ef9e26438a3de092","analyzedAt":"2026-08-15T01:39:07.505Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}