NanmiCoder/MediaCrawler · error
[BaiduTieBaLogin.begin]Invalid Login Type Currently only sup
Error message
[BaiduTieBaLogin.begin]Invalid Login Type Currently only supported qrcode or phone or cookies ...
What it means
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.
Source
Thrown at media_platform/tieba/login.py:76
current_cookie = await self.browser_context.cookies()
_, cookie_dict = utils.convert_cookies(current_cookie)
stoken = cookie_dict.get("STOKEN")
ptoken = cookie_dict.get("PTOKEN")
if stoken or ptoken:
return True
return False
async def begin(self):
"""Start login baidutieba"""
utils.logger.info("[BaiduTieBaLogin.begin] Begin login baidutieba ...")
if config.LOGIN_TYPE == "qrcode":
await self.login_by_qrcode()
elif config.LOGIN_TYPE == "phone":
await self.login_by_mobile()
elif config.LOGIN_TYPE == "cookie":
await self.login_by_cookies()
else:
raise ValueError("[BaiduTieBaLogin.begin]Invalid Login Type Currently only supported qrcode or phone or cookies ...")
async def login_by_mobile(self):
"""Login baidutieba by mobile"""
pass
async def login_by_qrcode(self):
"""login baidutieba website and keep webdriver login state"""
utils.logger.info("[BaiduTieBaLogin.login_by_qrcode] Begin login baidutieba by qrcode ...")
qrcode_img_selector = "xpath=//img[@class='tang-pass-qrcode-img']"
# find login qrcode
base64_qrcode_img = await utils.find_login_qrcode(
self.context_page,
selector=qrcode_img_selector
)
if not base64_qrcode_img:
utils.logger.info("[BaiduTieBaLogin.login_by_qrcode] login failed , have not found qrcode please check ....")
# if this website does not automatically popup login dialog box, we will manual click login button
await asyncio.sleep(0.5)View on GitHub (pinned to d6f7c5bb90)
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
Example fix
# before LOGIN_TYPE=phone # no-op stub for tieba # after LOGIN_TYPE=qrcode
Defensive patterns
Strategy: validation
Validate before calling
import config
assert config.LOGIN_TYPE in {"qrcode", "phone", "cookie"}, f"bad LOGIN_TYPE: {config.LOGIN_TYPE!r}" Type guard
def is_valid_tieba_login_type(value: str) -> bool:
return isinstance(value, str) and value.strip().lower() in {"qrcode", "phone", "cookie"} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- [KuaishouLogin.begin] Invalid Login Type Currently only supp
- playwright_page is required for browser-based sub-comment fe
- [BilibiliLogin.begin] Invalid Login Type Currently only supp
- [DouYinLogin.begin] Invalid Login Type Currently only suppor
- playwright_page is required for browser-based search
AI-assisted analysis of NanmiCoder/MediaCrawler@d6f7c5bb90 (2026-08-15).
Data as JSON: /api/errors/e8f29552ff346990.
Report an issue: GitHub.